Commit 9a266d11 authored by Kirill Smelkov's avatar Kirill Smelkov

X neotest/bench-cpu: Also benchmark sha1 for 2M; report size units as e.g. 4K not 4096B

parent 44529dbf
......@@ -846,10 +846,11 @@ bench_cpu() {
nrun sh -c "python -m test.pystone |tail -1 |sed -e \
\"s|^This machine benchmarks at \([0-9.]\+\) pystones/second$|Benchmark`hostname`/pystone 1 \1 pystone/s|\""
nrun tsha1.py 1024
nrun tsha1_go 1024
nrun tsha1.py 4096
nrun tsha1_go 4096
sizev="1024 4096 $((2*1024*1024))"
for size in $sizev; do
nrun tsha1.py $size
nrun tsha1_go $size
done
}
# bench_disk - benchmark direct (uncached) and cached random reads
......
......@@ -36,6 +36,20 @@ func dieusage() {
os.Exit(1)
}
const unitv = "BKMGT" // (2^10)^i represents by corresponding char suffix
// fmtsize formats size in human readable form
func fmtsize(size int) string {
const order = 1<<10
norder := 0
for size != 0 && (size % order) == 0 && (norder + 1 < len(unitv)) {
size /= order
norder += 1
}
return fmt.Sprintf("%d%c", size, unitv[norder])
}
func main() {
if len(os.Args) != 2 {
dieusage()
......@@ -67,5 +81,5 @@ func main() {
hostname = "?"
}
fmt.Printf("Benchmark%s/sha1/go/%dB %d\t%.3f µs/op\n", hostname, blksize, n, float64(δt) / float64(n) / float64(time.Microsecond))
fmt.Printf("Benchmark%s/sha1/go/%s %d\t%.3f µs/op\n", hostname, fmtsize(blksize), n, float64(δt) / float64(n) / float64(time.Microsecond))
}
......@@ -27,6 +27,18 @@ import hashlib
from time import time
import socket
# fmtsize formats size in human readable form
_unitv = "BKMGT" # (2^10)^i represents by corresponding char suffix
def fmtsize(size):
order = 1<<10
norder = 0
while size and (size % order) == 0 and (norder + 1 < len(_unitv)):
size //= order
norder += 1
return "%d%s" % (size, _unitv[norder])
def main():
blksize = int(sys.argv[1])
data = '\0'*blksize
......@@ -47,7 +59,7 @@ def main():
dt = tend - tstart
hostname = socket.gethostname()
print('Benchmark%s/sha1/py/%dB %d\t%.3f µs/op' % (hostname, blksize, n, dt * 1E6 / n))
print('Benchmark%s/sha1/py/%s %d\t%.3f µs/op' % (hostname, fmtsize(blksize), n, dt * 1E6 / n))
if __name__ == '__main__':
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment