fork(3) download
  1. import re
  2. import random
  3. import datetime
  4.  
  5. a = []
  6. n = 100_000
  7. for i in range(n):
  8. a.append(str(random.randint(0, 10000))+'/'+str(random.randint(0, 10000)))
  9.  
  10. pattern = re.compile(r'(.*)/(.*)')
  11. regex_matches = [None] * n
  12. start_regex = datetime.datetime.now()
  13. for i,s in enumerate(a):
  14. regex_matches[i] = pattern.findall(s)
  15. end_regex = datetime.datetime.now()
  16. print(end_regex - start_regex)
  17.  
  18. split_matches = [None] * n
  19. start_split = datetime.datetime.now()
  20. for i,s in enumerate(a):
  21. split_matches[i] = s.split('/')
  22. end_split = datetime.datetime.now()
  23. print(end_split - start_split)
Success #stdin #stdout 0.63s 75724KB
stdin
Standard input is empty
stdout
0:00:00.129082
0:00:00.080535