File: bench.py

package info (click to toggle)
rust-fasteval 0.2.4-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 952 kB
  • sloc: python: 14; makefile: 8
file content (21 lines) | stat: -rwxr-xr-x 532 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
#!/usr/bin/env python3

import time
import statistics

def calc():
    for i in range(100):
        x = 3.0 * (3.0 + 3.0) / 3.0

stats = []
for i in range(100):
    start = time.time()
    calc()
    stats.append((time.time()-start)*1_000_000_000)

avg = sum(stats)/len(stats)
stdev = statistics.stdev(stats, avg)

print("python_eval_only_100x:", int(avg), "ns  +/-", int(stdev))
print("It's very difficult to estimate the parse time in a fair way.  (Maybe 'time' the run of a PYC?  But that includes many proc startup costs...)")