-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
43 lines (29 loc) · 1.09 KB
/
README
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
perf.py
A simple command-line tool to benchmark Python code.
Usage:
$ perf.py --help
usage: perf.py [OPTION]... PATH
options:
-h, --help Print this help message and exit
--version Print program version and exit
-S, --show-source Display generated benchmark code
-B, --show-bytecode Display bytecode
-R, --show-results Display return values
-P, --show-python Display Python version
-n, --iterations N Number of iterations
-t, --threshold SECONDS Number of seconds to run a benchmark for
-g, --gc Enable garbage collection during benchmark runs
-l, --loop Keep loop overhead in benchmark timings
Example:
$ cat benchmark.py
NAME = "filename.tar.gz"
def split():
return NAME.split(".")[-1]
def rsplit():
return NAME.rsplit(".", 1)[1]
def rpartition():
return NAME.rpartition(".")[2]
$ perf.py benchmark.py
split : 146.13ns 1.00
rsplit : 128.06ns 0.88
rpartition: 106.97ns 0.73