[Python-Dev] Microbenchmarks (original) (raw)
Victor Stinner victor.stinner at gmail.com
Thu Sep 15 17:04:03 EDT 2016
- Previous message (by thread): [Python-Dev] Microbenchmarks
- Next message (by thread): [Python-Dev] [Python-checkins] cpython (2.7): properly handle the single null-byte file (closes #24022)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2016-09-15 21:33 GMT+02:00 Victor Stinner <victor.stinner at gmail.com>:
perf takes ~60 seconds by default. If you don't care of the accuracy, use --fast and it now only takes 20 seconds ;-)
Oops, I'm wrong. By default, a "single dot" (one worker process) takes less 1 second, so 20 dots (default) takes less than 20 seconds.
On the following example, the setup statement is quite expensive:
$ python3 -m timeit -s "d=dict.fromkeys(map(str,range(10**6)))" "list(d)"
The statement "list(d)" takes around 47 ms, but the setup statement takes 377 ms.
It seems like timeit executes the setup statement. Perf is based on timeit, and so each process runs the setup statement at least 4 times (1 warmup + 3 samples): 4*377 ms ~= 1.5 sec per process.
Replace range(106) with range(105) and the benchmark itself becomes much faster: 57 seconds => 15 seconds.
Victor
- Previous message (by thread): [Python-Dev] Microbenchmarks
- Next message (by thread): [Python-Dev] [Python-checkins] cpython (2.7): properly handle the single null-byte file (closes #24022)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]