Advertisement
sweeneyde

Stringbench suite runs for PR 22904

Oct 23rd, 2020 (edited)
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.51 KB | None | 0 0
  1. ############################################
  2. # Before PR 22904 #################
  3. ############################################
  4.  
  5. bytes unicode
  6. (in ms) (in ms) % comment
  7. ========== case conversion -- dense
  8. 0.24 0.25 98.5 ("WHERE IN THE WORLD IS CARMEN SAN DEIGO?"*10).lower() (*1000)
  9. 0.24 0.24 99.2 ("where in the world is carmen san deigo?"*10).upper() (*1000)
  10. ========== case conversion -- rare
  11. 0.24 0.24 99.5 ("Where in the world is Carmen San Deigo?"*10).lower() (*1000)
  12. 0.24 0.25 96.7 ("wHERE IN THE WORLD IS cARMEN sAN dEIGO?"*10).upper() (*1000)
  13. ========== concat 20 strings of words length 4 to 15
  14. 1.02 1.07 95.3 s1+s2+s3+s4+...+s20 (*1000)
  15. ========== concat two strings
  16. 0.06 0.06 93.6 "Andrew"+"Dalke" (*1000)
  17. ========== count AACT substrings in DNA example
  18. 0.55 0.70 77.7 dna.count("AACT") (*10)
  19. ========== count newlines
  20. 0.69 0.69 99.6 ...text.with.2000.newlines.count("\n") (*10)
  21. ========== early match, single character
  22. 0.12 0.11 107.5 ("A"*1000).find("A") (*1000)
  23. 0.24 0.03 834.4 "A" in "A"*1000 (*1000)
  24. 0.12 0.11 109.1 ("A"*1000).index("A") (*1000)
  25. 0.17 0.17 97.8 ("A"*1000).partition("A") (*1000)
  26. 0.13 0.12 106.3 ("A"*1000).rfind("A") (*1000)
  27. 0.13 0.12 108.5 ("A"*1000).rindex("A") (*1000)
  28. 0.16 0.17 98.1 ("A"*1000).rpartition("A") (*1000)
  29. 0.18 0.19 94.3 ("A"*1000).rsplit("A", 1) (*1000)
  30. 0.18 0.19 93.8 ("A"*1000).split("A", 1) (*1000)
  31. ========== early match, two characters
  32. 0.12 0.11 106.8 ("AB"*1000).find("AB") (*1000)
  33. 0.24 0.03 717.8 "AB" in "AB"*1000 (*1000)
  34. 0.12 0.11 107.2 ("AB"*1000).index("AB") (*1000)
  35. 0.18 0.18 100.7 ("AB"*1000).partition("AB") (*1000)
  36. 0.13 0.13 106.0 ("AB"*1000).rfind("AB") (*1000)
  37. 0.14 0.13 107.6 ("AB"*1000).rindex("AB") (*1000)
  38. 0.18 0.17 103.4 ("AB"*1000).rpartition("AB") (*1000)
  39. 0.19 0.20 96.8 ("AB"*1000).rsplit("AB", 1) (*1000)
  40. 0.19 0.20 97.3 ("AB"*1000).split("AB", 1) (*1000)
  41. ========== endswith multiple characters
  42. 0.10 0.10 97.4 "Andrew".endswith("Andrew") (*1000)
  43. ========== endswith multiple characters - not!
  44. 0.10 0.10 100.9 "Andrew".endswith("Anders") (*1000)
  45. ========== endswith single character
  46. 0.10 0.10 97.4 "Andrew".endswith("w") (*1000)
  47. ========== formatting a string type with a dict
  48. N/A 0.55 0.0 "The %(k1)s is %(k2)s the %(k3)s."%{"k1":"x","k2":"y","k3":"z",} (*1000)
  49. ========== join empty string, with 1 character sep
  50. N/A 0.01 0.0 "A".join("") (*100)
  51. ========== join empty string, with 5 character sep
  52. N/A 0.01 0.0 "ABCDE".join("") (*100)
  53. ========== join list of 100 words, with 1 character sep
  54. 1.28 1.16 110.3 "A".join(["Bob"]*100)) (*1000)
  55. ========== join list of 100 words, with 5 character sep
  56. 1.39 1.27 109.4 "ABCDE".join(["Bob"]*100)) (*1000)
  57. ========== join list of 26 characters, with 1 character sep
  58. 0.41 0.34 121.5 "A".join(list("ABC..Z")) (*1000)
  59. ========== join list of 26 characters, with 5 character sep
  60. 0.42 0.35 121.6 "ABCDE".join(list("ABC..Z")) (*1000)
  61. ========== join string with 26 characters, with 1 character sep
  62. N/A 0.65 0.0 "A".join("ABC..Z") (*1000)
  63. ========== join string with 26 characters, with 5 character sep
  64. N/A 0.66 0.0 "ABCDE".join("ABC..Z") (*1000)
  65. ========== late match, 100 characters
  66. 2.73 3.88 70.4 s="ABC"*33; ((s+"D")*500+s+"E").find(s+"E") (*100)
  67. 2.01 3.54 56.8 s="ABC"*33; ((s+"D")*500+"E"+s).find("E"+s) (*100)
  68. 1.66 2.36 70.2 s="ABC"*33; (s+"E") in ((s+"D")*300+s+"E") (*100)
  69. 2.74 3.89 70.5 s="ABC"*33; ((s+"D")*500+s+"E").index(s+"E") (*100)
  70. 3.93 4.00 98.4 s="ABC"*33; ((s+"D")*500+s+"E").partition(s+"E") (*100)
  71. 3.99 4.59 86.8 s="ABC"*33; ("E"+s+("D"+s)*500).rfind("E"+s) (*100)
  72. 1.64 2.23 73.3 s="ABC"*33; (s+"E"+("D"+s)*500).rfind(s+"E") (*100)
  73. 3.97 4.59 86.4 s="ABC"*33; ("E"+s+("D"+s)*500).rindex("E"+s) (*100)
  74. 4.69 4.67 100.3 s="ABC"*33; ("E"+s+("D"+s)*500).rpartition("E"+s) (*100)
  75. 4.09 2.82 145.0 s="ABC"*33; ("E"+s+("D"+s)*500).rsplit("E"+s, 1) (*100)
  76. 3.50 3.51 99.7 s="ABC"*33; ((s+"D")*500+s+"E").split(s+"E", 1) (*100)
  77. ========== late match, two characters
  78. 0.44 0.58 76.2 ("AB"*300+"C").find("BC") (*1000)
  79. 0.59 0.73 80.5 ("AB"*300+"CA").find("CA") (*1000)
  80. 0.55 0.49 112.5 "BC" in ("AB"*300+"C") (*1000)
  81. 0.45 0.58 76.5 ("AB"*300+"C").index("BC") (*1000)
  82. 0.61 0.62 98.6 ("AB"*300+"C").partition("BC") (*1000)
  83. 0.62 0.64 96.4 ("C"+"AB"*300).rfind("CA") (*1000)
  84. 0.57 0.65 87.5 ("BC"+"AB"*300).rfind("BC") (*1000)
  85. 0.62 0.64 96.5 ("C"+"AB"*300).rindex("CA") (*1000)
  86. 0.68 0.69 99.0 ("C"+"AB"*300).rpartition("CA") (*1000)
  87. 0.82 0.60 137.8 ("C"+"AB"*300).rsplit("CA", 1) (*1000)
  88. 0.63 0.61 103.0 ("AB"*300+"C").split("BC", 1) (*1000)
  89. ========== no match, single character
  90. 0.31 0.29 104.9 ("A"*1000).find("B") (*1000)
  91. 0.43 0.21 203.6 "B" in "A"*1000 (*1000)
  92. 0.24 0.24 103.2 ("A"*1000).partition("B") (*1000)
  93. 0.37 0.37 102.2 ("A"*1000).rfind("B") (*1000)
  94. 0.32 0.31 104.1 ("A"*1000).rpartition("B") (*1000)
  95. 0.34 0.33 102.4 ("A"*1000).rsplit("B", 1) (*1000)
  96. 0.59 0.33 176.6 ("A"*1000).split("B", 1) (*1000)
  97. ========== no match, two characters
  98. 1.12 1.63 68.8 ("AB"*1000).find("BC") (*1000)
  99. 1.61 2.11 76.2 ("AB"*1000).find("CA") (*1000)
  100. 1.25 1.54 80.8 "BC" in "AB"*1000 (*1000)
  101. 1.61 1.58 101.8 ("AB"*1000).partition("BC") (*1000)
  102. 1.59 1.90 83.5 ("AB"*1000).rfind("BC") (*1000)
  103. 1.77 1.87 94.7 ("AB"*1000).rfind("CA") (*1000)
  104. 1.85 1.82 101.5 ("AB"*1000).rpartition("BC") (*1000)
  105. 1.46 1.60 91.1 ("AB"*1000).rsplit("BC", 1) (*1000)
  106. 1.34 1.33 100.9 ("AB"*1000).split("BC", 1) (*1000)
  107. ========== quick replace multiple character match
  108. 0.03 0.03 103.5 ("A" + ("Z"*128*1024)).replace("AZZ", "BBZZ", 1) (*10)
  109. ========== quick replace single character match
  110. 0.03 0.03 102.5 ("A" + ("Z"*128*1024)).replace("A", "BB", 1) (*10)
  111. ========== repeat 1 character 10 times
  112. 0.05 0.06 81.8 "A"*10 (*1000)
  113. ========== repeat 1 character 1000 times
  114. 0.13 0.14 95.8 "A"*1000 (*1000)
  115. ========== repeat 5 characters 10 times
  116. 0.07 0.08 88.2 "ABCDE"*10 (*1000)
  117. ========== repeat 5 characters 1000 times
  118. 0.26 0.26 97.1 "ABCDE"*1000 (*1000)
  119. ========== replace and expand multiple characters, big string
  120. 1.27 1.71 74.3 "...text.with.2000.newlines...replace("\n", "\r\n") (*10)
  121. ========== replace multiple characters, dna
  122. 1.04 1.13 91.6 dna.replace("ATC", "ATT") (*10)
  123. ========== replace single character
  124. 0.10 0.09 109.9 "This is a test".replace(" ", "\t") (*1000)
  125. ========== replace single character, big string
  126. 0.40 0.56 72.0 "...text.with.2000.lines...replace("\n", " ") (*10)
  127. ========== replace/remove multiple characters
  128. 0.15 0.15 98.2 "When shall we three meet again?".replace("ee", "") (*1000)
  129. ========== split 1 whitespace
  130. 0.10 0.11 94.0 ("Here are some words. "*2).partition(" ") (*1000)
  131. 0.08 0.09 96.3 ("Here are some words. "*2).rpartition(" ") (*1000)
  132. 0.11 0.13 84.7 ("Here are some words. "*2).rsplit(None, 1) (*1000)
  133. 0.11 0.13 84.2 ("Here are some words. "*2).split(None, 1) (*1000)
  134. ========== split 2000 newlines
  135. 1.24 1.42 87.4 "...text...".rsplit("\n") (*10)
  136. 1.26 1.39 90.9 "...text...".split("\n") (*10)
  137. 1.35 1.68 80.0 "...text...".splitlines() (*10)
  138. ========== split newlines
  139. 0.14 0.16 86.6 "this\nis\na\ntest\n".rsplit("\n") (*1000)
  140. 0.14 0.16 82.6 "this\nis\na\ntest\n".split("\n") (*1000)
  141. 0.13 0.16 82.6 "this\nis\na\ntest\n".splitlines() (*1000)
  142. ========== split on multicharacter separator (dna)
  143. 0.76 0.69 109.9 dna.rsplit("ACTAT") (*10)
  144. 0.86 0.88 97.3 dna.split("ACTAT") (*10)
  145. ========== split on multicharacter separator (small)
  146. 0.31 0.34 91.4 "this--is--a--test--of--the--emergency--broadcast--system".rsplit("--") (*1000)
  147. 0.30 0.34 87.1 "this--is--a--test--of--the--emergency--broadcast--system".split("--") (*1000)
  148. ========== split whitespace (huge)
  149. 0.81 1.24 65.9 human_text.rsplit() (*10)
  150. 0.74 1.17 63.4 human_text.split() (*10)
  151. ========== split whitespace (small)
  152. 0.23 0.32 72.7 ("Here are some words. "*2).rsplit() (*1000)
  153. 0.24 0.32 74.8 ("Here are some words. "*2).split() (*1000)
  154. ========== startswith multiple characters
  155. 0.10 0.10 98.7 "Andrew".startswith("Andrew") (*1000)
  156. ========== startswith multiple characters - not!
  157. 0.10 0.10 102.0 "Andrew".startswith("Anders") (*1000)
  158. ========== startswith single character
  159. 0.10 0.10 99.7 "Andrew".startswith("A") (*1000)
  160. ========== strip terminal newline
  161. 0.06 0.13 44.5 s="Hello!\n"; s[:-1] if s[-1]=="\n" else s (*1000)
  162. 0.05 0.06 85.9 "\nHello!".rstrip() (*1000)
  163. 0.05 0.06 84.6 "Hello!\n".rstrip() (*1000)
  164. 0.05 0.06 84.8 "\nHello!\n".strip() (*1000)
  165. 0.05 0.06 83.9 "\nHello!".strip() (*1000)
  166. 0.05 0.06 84.6 "Hello!\n".strip() (*1000)
  167. ========== strip terminal spaces and tabs
  168. 0.05 0.07 72.3 "\t \tHello".rstrip() (*1000)
  169. 0.05 0.06 85.9 "Hello\t \t".rstrip() (*1000)
  170. 0.03 0.03 95.7 "Hello\t \t".strip() (*1000)
  171. ========== tab split
  172. 0.23 0.27 86.9 GFF3_example.rsplit("\t", 8) (*1000)
  173. 0.22 0.28 81.2 GFF3_example.rsplit("\t") (*1000)
  174. 0.22 0.25 86.1 GFF3_example.split("\t", 8) (*1000)
  175. 0.23 0.29 81.3 GFF3_example.split("\t") (*1000)
  176. 81.82 92.62 88.3 TOTAL
  177.  
  178.  
  179. ############################################
  180. # After PR 22904 #################
  181. ############################################
  182.  
  183.  
  184. 2020-10-23 18:41:57.374181
  185. bytes unicode
  186. (in ms) (in ms) % comment
  187. ========== case conversion -- dense
  188. 0.25 0.25 98.7 ("WHERE IN THE WORLD IS CARMEN SAN DEIGO?"*10).lower() (*1000)
  189. 0.24 0.25 97.4 ("where in the world is carmen san deigo?"*10).upper() (*1000)
  190. ========== case conversion -- rare
  191. 0.28 0.29 98.5 ("Where in the world is Carmen San Deigo?"*10).lower() (*1000)
  192. 0.24 0.25 97.8 ("wHERE IN THE WORLD IS cARMEN sAN dEIGO?"*10).upper() (*1000)
  193. ========== concat 20 strings of words length 4 to 15
  194. 1.05 1.03 101.8 s1+s2+s3+s4+...+s20 (*1000)
  195. ========== concat two strings
  196. 0.05 0.06 87.7 "Andrew"+"Dalke" (*1000)
  197. ========== count AACT substrings in DNA example
  198. 0.63 0.67 94.0 dna.count("AACT") (*10)
  199. ========== count newlines
  200. 0.72 0.72 100.1 ...text.with.2000.newlines.count("\n") (*10)
  201. ========== early match, single character
  202. 0.11 0.11 104.8 ("A"*1000).find("A") (*1000)
  203. 0.29 0.07 406.4 "A" in "A"*1000 (*1000)
  204. 0.19 0.18 106.3 ("A"*1000).index("A") (*1000)
  205. 0.17 0.17 98.3 ("A"*1000).partition("A") (*1000)
  206. 0.13 0.12 106.8 ("A"*1000).rfind("A") (*1000)
  207. 0.13 0.12 108.4 ("A"*1000).rindex("A") (*1000)
  208. 0.16 0.17 95.6 ("A"*1000).rpartition("A") (*1000)
  209. 0.18 0.19 94.5 ("A"*1000).rsplit("A", 1) (*1000)
  210. 0.18 0.20 93.8 ("A"*1000).split("A", 1) (*1000)
  211. ========== early match, two characters
  212. 0.12 0.11 104.8 ("AB"*1000).find("AB") (*1000)
  213. 0.24 0.03 742.4 "AB" in "AB"*1000 (*1000)
  214. 0.12 0.11 104.8 ("AB"*1000).index("AB") (*1000)
  215. 0.18 0.18 99.9 ("AB"*1000).partition("AB") (*1000)
  216. 0.13 0.12 105.2 ("AB"*1000).rfind("AB") (*1000)
  217. 0.13 0.12 108.1 ("AB"*1000).rindex("AB") (*1000)
  218. 0.18 0.18 96.6 ("AB"*1000).rpartition("AB") (*1000)
  219. 0.20 0.21 96.0 ("AB"*1000).rsplit("AB", 1) (*1000)
  220. 0.20 0.21 96.9 ("AB"*1000).split("AB", 1) (*1000)
  221. ========== endswith multiple characters
  222. 0.10 0.10 99.1 "Andrew".endswith("Andrew") (*1000)
  223. ========== endswith multiple characters - not!
  224. 0.10 0.10 101.0 "Andrew".endswith("Anders") (*1000)
  225. ========== endswith single character
  226. 0.10 0.10 99.0 "Andrew".endswith("w") (*1000)
  227. ========== formatting a string type with a dict
  228. N/A 0.55 0.0 "The %(k1)s is %(k2)s the %(k3)s."%{"k1":"x","k2":"y","k3":"z",} (*1000)
  229. ========== join empty string, with 1 character sep
  230. N/A 0.01 0.0 "A".join("") (*100)
  231. ========== join empty string, with 5 character sep
  232. N/A 0.01 0.0 "ABCDE".join("") (*100)
  233. ========== join list of 100 words, with 1 character sep
  234. 1.33 1.20 111.0 "A".join(["Bob"]*100)) (*1000)
  235. ========== join list of 100 words, with 5 character sep
  236. 1.42 1.26 113.1 "ABCDE".join(["Bob"]*100)) (*1000)
  237. ========== join list of 26 characters, with 1 character sep
  238. 0.43 0.33 129.2 "A".join(list("ABC..Z")) (*1000)
  239. ========== join list of 26 characters, with 5 character sep
  240. 0.43 0.33 131.7 "ABCDE".join(list("ABC..Z")) (*1000)
  241. ========== join string with 26 characters, with 1 character sep
  242. N/A 0.63 0.0 "A".join("ABC..Z") (*1000)
  243. ========== join string with 26 characters, with 5 character sep
  244. N/A 0.63 0.0 "ABCDE".join("ABC..Z") (*1000)
  245. ========== late match, 100 characters
  246. 6.06 6.01 100.8 s="ABC"*33; ((s+"D")*500+s+"E").find(s+"E") (*100)
  247. 0.92 0.91 101.4 s="ABC"*33; ((s+"D")*500+"E"+s).find("E"+s) (*100)
  248. 3.63 3.59 101.2 s="ABC"*33; (s+"E") in ((s+"D")*300+s+"E") (*100)
  249. 6.00 5.94 101.1 s="ABC"*33; ((s+"D")*500+s+"E").index(s+"E") (*100)
  250. 6.05 6.10 99.2 s="ABC"*33; ((s+"D")*500+s+"E").partition(s+"E") (*100)
  251. 2.64 4.07 64.9 s="ABC"*33; ("E"+s+("D"+s)*500).rfind("E"+s) (*100)
  252. 1.95 1.85 105.2 s="ABC"*33; (s+"E"+("D"+s)*500).rfind(s+"E") (*100)
  253. 2.64 3.97 66.4 s="ABC"*33; ("E"+s+("D"+s)*500).rindex("E"+s) (*100)
  254. 2.85 4.09 69.7 s="ABC"*33; ("E"+s+("D"+s)*500).rpartition("E"+s) (*100)
  255. 2.91 4.08 71.2 s="ABC"*33; ("E"+s+("D"+s)*500).rsplit("E"+s, 1) (*100)
  256. 6.04 6.02 100.3 s="ABC"*33; ((s+"D")*500+s+"E").split(s+"E", 1) (*100)
  257. ========== late match, two characters
  258. 0.55 0.56 98.4 ("AB"*300+"C").find("BC") (*1000)
  259. 0.64 0.70 91.4 ("AB"*300+"CA").find("CA") (*1000)
  260. 0.66 0.53 125.9 "BC" in ("AB"*300+"C") (*1000)
  261. 0.55 0.57 97.1 ("AB"*300+"C").index("BC") (*1000)
  262. 0.58 0.62 93.0 ("AB"*300+"C").partition("BC") (*1000)
  263. 0.47 0.60 78.0 ("C"+"AB"*300).rfind("CA") (*1000)
  264. 0.62 0.61 101.2 ("BC"+"AB"*300).rfind("BC") (*1000)
  265. 0.47 0.60 78.2 ("C"+"AB"*300).rindex("CA") (*1000)
  266. 0.48 0.66 73.4 ("C"+"AB"*300).rpartition("CA") (*1000)
  267. 0.52 0.69 74.8 ("C"+"AB"*300).rsplit("CA", 1) (*1000)
  268. 0.60 0.72 83.4 ("AB"*300+"C").split("BC", 1) (*1000)
  269. ========== no match, single character
  270. 0.32 0.32 100.5 ("A"*1000).find("B") (*1000)
  271. 0.45 0.21 210.6 "B" in "A"*1000 (*1000)
  272. 0.26 0.25 103.4 ("A"*1000).partition("B") (*1000)
  273. 0.38 0.36 105.1 ("A"*1000).rfind("B") (*1000)
  274. 0.33 0.31 104.3 ("A"*1000).rpartition("B") (*1000)
  275. 0.34 0.33 101.6 ("A"*1000).rsplit("B", 1) (*1000)
  276. 0.58 0.33 175.4 ("A"*1000).split("B", 1) (*1000)
  277. ========== no match, two characters
  278. 1.49 1.51 98.7 ("AB"*1000).find("BC") (*1000)
  279. 1.77 2.00 88.5 ("AB"*1000).find("CA") (*1000)
  280. 1.63 1.54 105.9 "BC" in "AB"*1000 (*1000)
  281. 1.45 1.45 99.6 ("AB"*1000).partition("BC") (*1000)
  282. 1.78 1.75 101.7 ("AB"*1000).rfind("BC") (*1000)
  283. 1.25 1.75 71.8 ("AB"*1000).rfind("CA") (*1000)
  284. 1.41 1.70 83.0 ("AB"*1000).rpartition("BC") (*1000)
  285. 1.45 1.72 84.7 ("AB"*1000).rsplit("BC", 1) (*1000)
  286. 1.48 1.49 99.2 ("AB"*1000).split("BC", 1) (*1000)
  287. ========== quick replace multiple character match
  288. 0.04 0.04 102.5 ("A" + ("Z"*128*1024)).replace("AZZ", "BBZZ", 1) (*10)
  289. ========== quick replace single character match
  290. 0.04 0.04 100.8 ("A" + ("Z"*128*1024)).replace("A", "BB", 1) (*10)
  291. ========== repeat 1 character 10 times
  292. 0.05 0.06 84.6 "A"*10 (*1000)
  293. ========== repeat 1 character 1000 times
  294. 0.13 0.14 94.8 "A"*1000 (*1000)
  295. ========== repeat 5 characters 10 times
  296. 0.07 0.09 78.7 "ABCDE"*10 (*1000)
  297. ========== repeat 5 characters 1000 times
  298. 0.25 0.26 96.6 "ABCDE"*1000 (*1000)
  299. ========== replace and expand multiple characters, big string
  300. 1.28 1.74 73.2 "...text.with.2000.newlines...replace("\n", "\r\n") (*10)
  301. ========== replace multiple characters, dna
  302. 1.01 1.06 95.0 dna.replace("ATC", "ATT") (*10)
  303. ========== replace single character
  304. 0.09 0.09 104.1 "This is a test".replace(" ", "\t") (*1000)
  305. ========== replace single character, big string
  306. 0.41 0.52 78.4 "...text.with.2000.lines...replace("\n", " ") (*10)
  307. ========== replace/remove multiple characters
  308. 0.15 0.15 94.4 "When shall we three meet again?".replace("ee", "") (*1000)
  309. ========== split 1 whitespace
  310. 0.10 0.11 94.0 ("Here are some words. "*2).partition(" ") (*1000)
  311. 0.08 0.09 90.3 ("Here are some words. "*2).rpartition(" ") (*1000)
  312. 0.11 0.13 83.7 ("Here are some words. "*2).rsplit(None, 1) (*1000)
  313. 0.10 0.13 82.8 ("Here are some words. "*2).split(None, 1) (*1000)
  314. ========== split 2000 newlines
  315. 1.24 1.41 88.1 "...text...".rsplit("\n") (*10)
  316. 1.26 1.40 90.2 "...text...".split("\n") (*10)
  317. 1.34 1.69 79.4 "...text...".splitlines() (*10)
  318. ========== split newlines
  319. 0.14 0.17 85.4 "this\nis\na\ntest\n".rsplit("\n") (*1000)
  320. 0.14 0.17 84.7 "this\nis\na\ntest\n".split("\n") (*1000)
  321. 0.14 0.17 81.8 "this\nis\na\ntest\n".splitlines() (*1000)
  322. ========== split on multicharacter separator (dna)
  323. 0.67 0.83 81.0 dna.rsplit("ACTAT") (*10)
  324. 0.83 0.89 92.7 dna.split("ACTAT") (*10)
  325. ========== split on multicharacter separator (small)
  326. 0.33 0.37 88.4 "this--is--a--test--of--the--emergency--broadcast--system".rsplit("--") (*1000)
  327. 0.34 0.39 87.4 "this--is--a--test--of--the--emergency--broadcast--system".split("--") (*1000)
  328. ========== split whitespace (huge)
  329. 0.77 1.21 63.6 human_text.rsplit() (*10)
  330. 0.75 1.12 66.8 human_text.split() (*10)
  331. ========== split whitespace (small)
  332. 0.23 0.33 69.7 ("Here are some words. "*2).rsplit() (*1000)
  333. 0.23 0.32 73.4 ("Here are some words. "*2).split() (*1000)
  334. ========== startswith multiple characters
  335. 0.10 0.10 98.9 "Andrew".startswith("Andrew") (*1000)
  336. ========== startswith multiple characters - not!
  337. 0.10 0.10 101.6 "Andrew".startswith("Anders") (*1000)
  338. ========== startswith single character
  339. 0.10 0.10 99.7 "Andrew".startswith("A") (*1000)
  340. ========== strip terminal newline
  341. 0.05 0.13 41.2 s="Hello!\n"; s[:-1] if s[-1]=="\n" else s (*1000)
  342. 0.05 0.06 82.5 "\nHello!".rstrip() (*1000)
  343. 0.05 0.06 84.6 "Hello!\n".rstrip() (*1000)
  344. 0.05 0.07 71.7 "\nHello!\n".strip() (*1000)
  345. 0.05 0.06 83.9 "\nHello!".strip() (*1000)
  346. 0.05 0.06 84.7 "Hello!\n".strip() (*1000)
  347. ========== strip terminal spaces and tabs
  348. 0.05 0.06 81.1 "\t \tHello".rstrip() (*1000)
  349. 0.05 0.06 86.8 "Hello\t \t".rstrip() (*1000)
  350. 0.03 0.03 93.6 "Hello\t \t".strip() (*1000)
  351. ========== tab split
  352. 0.23 0.27 83.8 GFF3_example.rsplit("\t", 8) (*1000)
  353. 0.22 0.26 82.9 GFF3_example.rsplit("\t") (*1000)
  354. 0.21 0.25 82.0 GFF3_example.split("\t", 8) (*1000)
  355. 0.23 0.31 74.8 GFF3_example.split("\t") (*1000)
  356. 88.60 99.03 89.5 TOTAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement