nim-zippy/tests/benchmark.nim

107 lines
3.3 KiB
Nim
Raw Normal View History

2020-10-29 01:17:33 +00:00
import miniz, nimPNG/nimz, std/monotimes, strformat, zip/zlib, zippy
2020-10-17 07:10:13 +00:00
2020-10-28 05:29:07 +00:00
const
2020-11-01 22:16:36 +00:00
zs = [
2020-10-28 05:29:07 +00:00
"randtest3.z",
"rfctest3.z",
"alice29.txt.z",
"urls.10K.z",
"fixed.z"
]
2020-11-01 22:16:36 +00:00
golds = [
2020-11-02 19:59:28 +00:00
# "rfctest1.gold",
"tor-list.gold",
2020-11-01 22:16:36 +00:00
]
2020-11-02 19:59:28 +00:00
iterations = 100
2020-10-14 04:09:43 +00:00
2020-11-01 22:16:36 +00:00
# block guzba_zippy_uncompress:
# echo "https://github.com/guzba/zippy uncompress"
# for z in zs:
# let
# compressed = readFile(&"tests/data/{z}")
# start = getMonoTime().ticks
# var c: int
# for i in 0 ..< iterations:
# let uncompressed = zippy.uncompress(compressed)
# inc(c, uncompressed.len)
# let delta = float64(getMonoTime().ticks - start) / 1000000000.0
# echo &" {z}: {delta:.4f}s [{c}]"
2020-10-28 05:29:07 +00:00
2020-11-01 22:16:36 +00:00
block guzba_zippy_compress:
echo "https://github.com/guzba/zippy compress"
for gold in golds:
2020-10-28 05:29:07 +00:00
let
2020-11-01 22:16:36 +00:00
uncompressed = readFile(&"tests/data/{gold}")
2020-10-28 05:29:07 +00:00
start = getMonoTime().ticks
var c: int
for i in 0 ..< iterations:
2020-11-01 22:16:36 +00:00
let compressed = zippy.compress(uncompressed)
inc(c, compressed.len)
2020-10-28 05:29:07 +00:00
let delta = float64(getMonoTime().ticks - start) / 1000000000.0
2020-11-01 22:16:36 +00:00
echo &" {gold}: {delta:.4f}s [{c}]"
# block treeform_miniz_uncompress:
# echo "https://github.com/treeform/miniz uncompress"
# for z in zs:
# let
# compressed = readFile(&"tests/data/{z}")
# start = getMonoTime().ticks
# var c: int
# for i in 0 ..< iterations:
# let uncompressed = miniz.uncompress(compressed)
# inc(c, uncompressed.len)
# let delta = float64(getMonoTime().ticks - start) / 1000000000.0
# echo &" {z}: {delta:.4f}s [{c}]"
2020-10-28 06:10:36 +00:00
2020-11-02 00:51:35 +00:00
block treeform_miniz_compress:
echo "https://github.com/treeform/miniz compress"
for gold in golds:
let
uncompressed = readFile(&"tests/data/{gold}")
start = getMonoTime().ticks
var c: int
for i in 0 ..< iterations:
let compressed = miniz.compress(uncompressed, 1)
inc(c, compressed.len)
let delta = float64(getMonoTime().ticks - start) / 1000000000.0
echo &" {gold}: {delta:.4f}s [{c}]"
2020-11-01 22:16:36 +00:00
# block nimlang_zip_uncompress: # Requires zlib1.dll
# echo "https://github.com/nim-lang/zip uncompress"
# for z in zs:
# let
# compressed = readFile(&"tests/data/{z}")
# start = getMonoTime().ticks
# var c: int
# for i in 0 ..< iterations:
# let uncompressed = zlib.uncompress(compressed, stream = ZLIB_STREAM)
# inc(c, uncompressed.len)
# let delta = float64(getMonoTime().ticks - start) / 1000000000.0
# echo &" {z}: {delta:.4f}s [{c}]"
# block jangko_nimPNG_uncompress:
# echo "https://github.com/jangko/nimPNG uncompress"
# for z in zs:
# let
# compressed = readFile(&"tests/data/{z}")
# start = getMonoTime().ticks
# var c: int
# for i in 0 ..< iterations:
# let uncompressed = zlib_decompress(nzInflateInit(compressed))
# inc(c, uncompressed.len)
# let delta = float64(getMonoTime().ticks - start) / 1000000000.0
# echo &" {z}: {delta:.4f}s [{c}]"
2020-10-28 18:31:23 +00:00
2020-11-02 00:51:35 +00:00
block jangko_nimPNG_compress:
echo "https://github.com/jangko/nimPNG compress"
for gold in golds:
let
uncompressed = readFile(&"tests/data/{gold}")
start = getMonoTime().ticks
var c: int
for i in 0 ..< iterations:
let compressed = zlib_compress(nzDeflateInit(uncompressed))
inc(c, compressed.len)
let delta = float64(getMonoTime().ticks - start) / 1000000000.0
echo &" {gold}: {delta:.4f}s [{c}]"