File: _performance_2.py

package info (click to toggle)
pydevd 2.9.5%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,880 kB
  • sloc: python: 75,138; cpp: 1,851; sh: 310; makefile: 40; ansic: 4
file content (25 lines) | stat: -rw-r--r-- 566 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
23
24
25
import time
import sys
import itertools

from itertools import groupby
count = itertools.count(0)


def next_val():
    return next(count) % 25


start_time = time.time()
letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

# create an array of random strings of 40 characters each
l = sorted([''.join([letters[next_val()] for _ in range(40)]) for _ in range(10000)])
# group by the first two characters
g = {k: list(v) for k, v in groupby(l, lambda x: x[:2])}

if False:
    pass  # Breakpoint here

print('TotalTime>>%s<<' % (time.time() - start_time,))
print('TEST SUCEEDED')