nim-zippy/tests/benchmark.nim

128 lines
4.1 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-03 16:58:23 +00:00
zs = [
"randtest3.z",
"rfctest3.z",
"alice29.txt.z",
"urls.10K.z",
"fixed.z"
]
2020-11-01 22:16:36 +00:00
golds = [
2020-11-02 21:34:26 +00:00
# "randtest1.gold",
2020-11-03 03:43:00 +00:00
# "randtest2.gold",
# "randtest3.gold",
2020-11-02 21:43:54 +00:00
"rfctest1.gold",
2020-11-07 04:17:22 +00:00
"rfctest2.gold",
"rfctest3.gold",
2020-11-02 21:43:54 +00:00
# "tor-list.gold",
2020-11-02 21:34:26 +00:00
# "zerotest1.gold",
# "zerotest2.gold",
# "zerotest3.gold",
2020-11-01 22:16:36 +00:00
]
2020-11-07 04:17:22 +00:00
iterations = 1000
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-08 06:40:17 +00:00
let compressed = zippy.compress(uncompressed, dfZlib)
2020-11-01 22:16:36 +00:00
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-07 06:35:04 +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}]"
2020-11-07 06:35:04 +00:00
# block nimlang_zip_compress: # Requires zlib1.dll
# echo "https://github.com/nim-lang/zip 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(uncompressed, stream = ZLIB_STREAM)
# inc(c, compressed.len)
# let delta = float64(getMonoTime().ticks - start) / 1000000000.0
# echo &" {gold}: {delta:.4f}s [{c}]"
2020-11-07 04:17:22 +00:00
2020-11-01 22:16:36 +00:00
# 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 20:08:12 +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}]"