File: findall.py

package info (click to toggle)
rednotebook 2.21%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,580 kB
  • sloc: python: 9,111; xml: 128; sh: 46; makefile: 11
file content (23 lines) | stat: -rwxr-xr-x 537 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python

import os.path
import sys
import timeit

DIR = os.path.dirname(os.path.abspath(__file__))
REPO = os.path.dirname(os.path.dirname(DIR))

sys.path.insert(0, REPO)

N = 2500
TEXTS = ["aa " * N, "\\\\ " * N, "\\  " * N, "== " * N, "$$ " * N, "$= " * N]
ITERATIONS = 10 ** 0

for text in TEXTS:
    timer = timeit.Timer(
        "HASHTAG.findall(text)",
        setup='from rednotebook.data import HASHTAG; text = "{text}"'.format(
            **locals()
        ),
    )
    print(text[:10], timer.timeit(ITERATIONS))