aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2018-12-02 18:08:48 +0100
committerpacien2018-12-02 18:08:48 +0100
commit31ecb9abcdfea2e2f559a7fe15d64458e5c0a901 (patch)
tree82fd4bd00b10b9e8c65c43e3b9d34d39465f09fa
parent3a3b727f09ad4a2f610649d8a9ea7deb36d3075d (diff)
downloadgziplike-31ecb9abcdfea2e2f559a7fe15d64458e5c0a901.tar.gz
add timing and compression ratio
-rw-r--r--tests/tgziplike.nim30
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/tgziplike.nim b/tests/tgziplike.nim
index 2b79240..836e4be 100644
--- a/tests/tgziplike.nim
+++ b/tests/tgziplike.nim
@@ -14,27 +14,27 @@
14# You should have received a copy of the GNU Affero General Public License 14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <https://www.gnu.org/licenses/>. 15# along with this program. If not, see <https://www.gnu.org/licenses/>.
16 16
17import unittest, os, ospaths, osproc 17import unittest, os, ospaths, osproc, times
18import gziplike 18import gziplike
19 19
20const tempDir = "tmp"
21
22suite "main": 20suite "main":
21 const tempDir = "tmp"
22
23 proc testIdentity(input: string, intermediate = tempDir / "compressed", final = tempDir / "decompressed"): bool =
24 let compressionStartTime = getTime()
25 compress.transform(input, intermediate)
26 echo("compression done in ", getTime() - compressionStartTime)
27 echo("compression ratio: ", (intermediate.getFileSize() * 100) div input.getFileSize(), "%")
28 let decompressionStartTime = getTime()
29 decompress.transform(intermediate, final)
30 echo("decompression done in ", getTime() - decompressionStartTime)
31 startProcess("cmp", args=[input, final], options={poUsePath}).waitForExit() == 0
32
23 setup: createDir(tempDir) 33 setup: createDir(tempDir)
24 teardown: removeDir(tempDir) 34 teardown: removeDir(tempDir)
25 35
26 test "identity (text)": 36 test "identity (text)":
27 let input = "license.md" 37 check testIdentity("license.md")
28 let intermediate = tempDir / "compressed"
29 let final = tempDir / "decompressed"
30 compress.transform(input, intermediate)
31 decompress.transform(intermediate, final)
32 check startProcess("cmp", args=[input, final], options={poUsePath}).waitForExit() == 0
33 38
34 test "identity (binary)": 39 test "identity (binary)":
35 let input = "tests" / "tgziplike" 40 check testIdentity("tests" / "tgziplike")
36 let intermediate = tempDir / "compressed"
37 let final = tempDir / "decompressed"
38 compress.transform(input, intermediate)
39 decompress.transform(intermediate, final)
40 check startProcess("cmp", args=[input, final], options={poUsePath}).waitForExit() == 0