File: findall.py

package info (click to toggle)
rednotebook 2.39%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,956 kB
  • sloc: python: 9,570; javascript: 4,103; xml: 128; sh: 58; makefile: 11
file content (22 lines) | stat: -rwxr-xr-x 496 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/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=f'from rednotebook.data import HASHTAG; text = "{text}"',
    )
    print(text[:10], timer.timeit(ITERATIONS))