test_stringview_performance.py 552 Bytes
Newer Older
1
2
#!/usr/bin/python

eckhart's avatar
eckhart committed
3
4
5
6
import sys

sys.path.append('../')

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from DHParser.stringview import StringView
from timeit import timeit
import re

sv = StringView("          01234567890          ")
rx = re.compile('\s*')

print(timeit('s = sv[10:21]', number=5_000_000, globals=globals()))


print(timeit('m=sv.match(rx)', number=5_000_000, globals=globals()))


print(timeit('sv.strip()', number=10_000_000, globals=globals()))

sv = StringView("100, 200, 300, 400, 500, 600, 700, 800, 900")

print(timeit('sv.split(", ")', number=5_000_000, globals=globals()))