Advertisement
sweeneyde

Stringbench suite runs for PR 22679

Oct 17th, 2020 (edited)
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.34 KB | None | 0 0
  1. ############################################
  2. # Before PR 22679 #################
  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. # After PR 22679 #################
  180. ############################################
  181.  
  182. bytes unicode
  183. (in ms) (in ms) % comment
  184. ========== case conversion -- dense
  185. 0.24 0.25 96.0 ("WHERE IN THE WORLD IS CARMEN SAN DEIGO?"*10).lower() (*1000)
  186. 0.24 0.18 130.7 ("where in the world is carmen san deigo?"*10).upper() (*1000)
  187. ========== case conversion -- rare
  188. 0.24 0.25 97.0 ("Where in the world is Carmen San Deigo?"*10).lower() (*1000)
  189. 0.24 0.18 131.3 ("wHERE IN THE WORLD IS cARMEN sAN dEIGO?"*10).upper() (*1000)
  190. ========== concat 20 strings of words length 4 to 15
  191. 1.04 1.09 94.6 s1+s2+s3+s4+...+s20 (*1000)
  192. ========== concat two strings
  193. 0.06 0.06 88.8 "Andrew"+"Dalke" (*1000)
  194. ========== count AACT substrings in DNA example
  195. 0.56 0.55 101.4 dna.count("AACT") (*10)
  196. ========== count newlines
  197. 0.72 0.70 102.0 ...text.with.2000.newlines.count("\n") (*10)
  198. ========== early match, single character
  199. 0.12 0.11 107.0 ("A"*1000).find("A") (*1000)
  200. 0.24 0.03 854.3 "A" in "A"*1000 (*1000)
  201. 0.12 0.11 109.6 ("A"*1000).index("A") (*1000)
  202. 0.17 0.17 97.4 ("A"*1000).partition("A") (*1000)
  203. 0.13 0.12 105.0 ("A"*1000).rfind("A") (*1000)
  204. 0.13 0.12 109.7 ("A"*1000).rindex("A") (*1000)
  205. 0.16 0.17 96.9 ("A"*1000).rpartition("A") (*1000)
  206. 0.19 0.20 95.5 ("A"*1000).rsplit("A", 1) (*1000)
  207. 0.19 0.19 97.3 ("A"*1000).split("A", 1) (*1000)
  208. ========== early match, two characters
  209. 0.12 0.11 108.1 ("AB"*1000).find("AB") (*1000)
  210. 0.24 0.03 729.1 "AB" in "AB"*1000 (*1000)
  211. 0.12 0.11 109.5 ("AB"*1000).index("AB") (*1000)
  212. 0.18 0.18 97.8 ("AB"*1000).partition("AB") (*1000)
  213. 0.13 0.13 105.1 ("AB"*1000).rfind("AB") (*1000)
  214. 0.14 0.13 107.5 ("AB"*1000).rindex("AB") (*1000)
  215. 0.18 0.18 99.6 ("AB"*1000).rpartition("AB") (*1000)
  216. 0.20 0.21 96.1 ("AB"*1000).rsplit("AB", 1) (*1000)
  217. 0.20 0.21 95.6 ("AB"*1000).split("AB", 1) (*1000)
  218. ========== endswith multiple characters
  219. 0.10 0.10 99.7 "Andrew".endswith("Andrew") (*1000)
  220. ========== endswith multiple characters - not!
  221. 0.10 0.10 101.0 "Andrew".endswith("Anders") (*1000)
  222. ========== endswith single character
  223. 0.10 0.10 99.3 "Andrew".endswith("w") (*1000)
  224. ========== formatting a string type with a dict
  225. N/A 0.55 0.0 "The %(k1)s is %(k2)s the %(k3)s."%{"k1":"x","k2":"y","k3":"z",} (*1000)
  226. ========== join empty string, with 1 character sep
  227. N/A 0.01 0.0 "A".join("") (*100)
  228. ========== join empty string, with 5 character sep
  229. N/A 0.01 0.0 "ABCDE".join("") (*100)
  230. ========== join list of 100 words, with 1 character sep
  231. 1.30 1.18 110.4 "A".join(["Bob"]*100)) (*1000)
  232. ========== join list of 100 words, with 5 character sep
  233. 1.40 1.27 110.4 "ABCDE".join(["Bob"]*100)) (*1000)
  234. ========== join list of 26 characters, with 1 character sep
  235. 0.43 0.32 131.6 "A".join(list("ABC..Z")) (*1000)
  236. ========== join list of 26 characters, with 5 character sep
  237. 0.43 0.33 131.2 "ABCDE".join(list("ABC..Z")) (*1000)
  238. ========== join string with 26 characters, with 1 character sep
  239. N/A 0.63 0.0 "A".join("ABC..Z") (*1000)
  240. ========== join string with 26 characters, with 5 character sep
  241. N/A 0.64 0.0 "ABCDE".join("ABC..Z") (*1000)
  242. ========== late match, 100 characters
  243. 0.17 0.15 116.3 s="ABC"*33; ((s+"D")*500+s+"E").find(s+"E") (*100)
  244. 0.89 0.87 101.8 s="ABC"*33; ((s+"D")*500+"E"+s).find("E"+s) (*100)
  245. 0.15 0.13 111.5 s="ABC"*33; (s+"E") in ((s+"D")*300+s+"E") (*100)
  246. 0.17 0.15 112.4 s="ABC"*33; ((s+"D")*500+s+"E").index(s+"E") (*100)
  247. 0.30 0.27 108.0 s="ABC"*33; ((s+"D")*500+s+"E").partition(s+"E") (*100)
  248. 3.13 2.51 124.5 s="ABC"*33; ("E"+s+("D"+s)*500).rfind("E"+s) (*100)
  249. 1.54 1.82 84.5 s="ABC"*33; (s+"E"+("D"+s)*500).rfind(s+"E") (*100)
  250. 3.18 2.53 125.8 s="ABC"*33; ("E"+s+("D"+s)*500).rindex("E"+s) (*100)
  251. 3.37 2.66 126.9 s="ABC"*33; ("E"+s+("D"+s)*500).rpartition("E"+s) (*100)
  252. 3.39 2.62 129.5 s="ABC"*33; ("E"+s+("D"+s)*500).rsplit("E"+s, 1) (*100)
  253. 0.30 0.28 106.0 s="ABC"*33; ((s+"D")*500+s+"E").split(s+"E", 1) (*100)
  254. ========== late match, two characters
  255. 0.57 0.48 120.2 ("AB"*300+"C").find("BC") (*1000)
  256. 0.56 0.72 77.5 ("AB"*300+"CA").find("CA") (*1000)
  257. 0.66 0.37 177.7 "BC" in ("AB"*300+"C") (*1000)
  258. 0.57 0.49 116.5 ("AB"*300+"C").index("BC") (*1000)
  259. 0.72 0.52 137.2 ("AB"*300+"C").partition("BC") (*1000)
  260. 0.49 0.49 101.6 ("C"+"AB"*300).rfind("CA") (*1000)
  261. 0.51 0.57 89.3 ("BC"+"AB"*300).rfind("BC") (*1000)
  262. 0.50 0.49 101.2 ("C"+"AB"*300).rindex("CA") (*1000)
  263. 0.61 0.54 113.5 ("C"+"AB"*300).rpartition("CA") (*1000)
  264. 0.63 0.57 112.0 ("C"+"AB"*300).rsplit("CA", 1) (*1000)
  265. 0.74 0.54 138.2 ("AB"*300+"C").split("BC", 1) (*1000)
  266. ========== no match, single character
  267. 0.30 0.29 103.7 ("A"*1000).find("B") (*1000)
  268. 0.43 0.20 212.9 "B" in "A"*1000 (*1000)
  269. 0.24 0.24 100.1 ("A"*1000).partition("B") (*1000)
  270. 0.37 0.37 102.4 ("A"*1000).rfind("B") (*1000)
  271. 0.32 0.31 104.0 ("A"*1000).rpartition("B") (*1000)
  272. 0.33 0.33 102.3 ("A"*1000).rsplit("B", 1) (*1000)
  273. 0.58 0.33 178.3 ("A"*1000).split("B", 1) (*1000)
  274. ========== no match, two characters
  275. 1.52 1.24 122.9 ("AB"*1000).find("BC") (*1000)
  276. 1.51 2.03 74.6 ("AB"*1000).find("CA") (*1000)
  277. 1.62 1.14 141.4 "BC" in "AB"*1000 (*1000)
  278. 1.93 1.18 163.4 ("AB"*1000).partition("BC") (*1000)
  279. 1.41 1.64 85.7 ("AB"*1000).rfind("BC") (*1000)
  280. 1.33 1.34 99.5 ("AB"*1000).rfind("CA") (*1000)
  281. 1.79 1.52 117.5 ("AB"*1000).rpartition("BC") (*1000)
  282. 1.59 1.58 100.9 ("AB"*1000).rsplit("BC", 1) (*1000)
  283. 1.96 1.20 163.7 ("AB"*1000).split("BC", 1) (*1000)
  284. ========== quick replace multiple character match
  285. 0.03 0.04 89.6 ("A" + ("Z"*128*1024)).replace("AZZ", "BBZZ", 1) (*10)
  286. ========== quick replace single character match
  287. 0.03 0.04 87.9 ("A" + ("Z"*128*1024)).replace("A", "BB", 1) (*10)
  288. ========== repeat 1 character 10 times
  289. 0.05 0.06 87.6 "A"*10 (*1000)
  290. ========== repeat 1 character 1000 times
  291. 0.13 0.14 92.0 "A"*1000 (*1000)
  292. ========== repeat 5 characters 10 times
  293. 0.07 0.08 85.8 "ABCDE"*10 (*1000)
  294. ========== repeat 5 characters 1000 times
  295. 0.27 0.27 98.0 "ABCDE"*1000 (*1000)
  296. ========== replace and expand multiple characters, big string
  297. 1.28 1.64 78.1 "...text.with.2000.newlines...replace("\n", "\r\n") (*10)
  298. 1.04 0.96 109.2 dna.replace("ATC", "ATT") (*10)
  299. 0.09 0.09 104.2 "This is a test".replace(" ", "\t") (*1000)
  300. ========== replace single character, big string
  301. 0.41 0.50 81.9 "...text.with.2000.lines...replace("\n", " ") (*10)
  302. ========== replace/remove multiple characters
  303. 0.15 0.15 102.5 "When shall we three meet again?".replace("ee", "") (*1000)
  304. ========== split 1 whitespace
  305. 0.10 0.11 92.8 ("Here are some words. "*2).partition(" ") (*1000)
  306. 0.08 0.09 92.7 ("Here are some words. "*2).rpartition(" ") (*1000)
  307. 0.11 0.13 87.3 ("Here are some words. "*2).rsplit(None, 1) (*1000)
  308. 0.11 0.13 85.1 ("Here are some words. "*2).split(None, 1) (*1000)
  309. ========== split 2000 newlines
  310. 1.24 1.45 85.3 "...text...".rsplit("\n") (*10)
  311. 1.25 1.41 89.2 "...text...".split("\n") (*10)
  312. 1.31 1.68 78.3 "...text...".splitlines() (*10)
  313. ========== split newlines
  314. 0.14 0.16 83.4 "this\nis\na\ntest\n".rsplit("\n") (*1000)
  315. 0.14 0.16 84.6 "this\nis\na\ntest\n".split("\n") (*1000)
  316. 0.13 0.16 77.2 "this\nis\na\ntest\n".splitlines() (*1000)
  317. ========== split on multicharacter separator (dna)
  318. 0.76 0.70 108.5 dna.rsplit("ACTAT") (*10)
  319. 0.93 0.84 111.8 dna.split("ACTAT") (*10)
  320. 0.33 0.37 89.6 "this--is--a--test--of--the--emergency--broadcast--system".rsplit("--") (*1000)
  321. 0.34 0.38 87.8 "this--is--a--test--of--the--emergency--broadcast--system".split("--") (*1000)
  322. ========== split whitespace (huge)
  323. 0.78 1.21 64.5 human_text.rsplit() (*10)
  324. 0.75 1.12 67.3 human_text.split() (*10)
  325. ========== split whitespace (small)
  326. 0.23 0.33 70.0 ("Here are some words. "*2).rsplit() (*1000)
  327. 0.24 0.31 76.3 ("Here are some words. "*2).split() (*1000)
  328. ========== startswith multiple characters
  329. 0.10 0.10 99.2 "Andrew".startswith("Andrew") (*1000)
  330. ========== startswith multiple characters - not!
  331. 0.10 0.10 102.2 "Andrew".startswith("Anders") (*1000)
  332. ========== startswith single character
  333. 0.10 0.10 98.5 "Andrew".startswith("A") (*1000)
  334. ========== strip terminal newline
  335. 0.06 0.13 43.8 s="Hello!\n"; s[:-1] if s[-1]=="\n" else s (*1000)
  336. 0.05 0.06 84.9 "\nHello!".rstrip() (*1000)
  337. 0.05 0.06 82.4 "Hello!\n".rstrip() (*1000)
  338. 0.05 0.06 83.7 "\nHello!\n".strip() (*1000)
  339. 0.05 0.06 83.9 "\nHello!".strip() (*1000)
  340. 0.05 0.06 84.6 "Hello!\n".strip() (*1000)
  341. ========== strip terminal spaces and tabs
  342. 0.05 0.06 84.6 "\t \tHello".rstrip() (*1000)
  343. 0.05 0.06 83.7 "Hello\t \t".rstrip() (*1000)
  344. 0.03 0.03 92.6 "Hello\t \t".strip() (*1000)
  345. ========== tab split
  346. 0.23 0.27 84.0 GFF3_example.rsplit("\t", 8) (*1000)
  347. 0.21 0.26 83.5 GFF3_example.rsplit("\t") (*1000)
  348. 0.21 0.25 83.6 GFF3_example.split("\t", 8) (*1000)
  349. 0.23 0.32 72.9 GFF3_example.split("\t") (*1000)
  350. 64.70 62.41 103.7 TOTAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement