summaryrefslogtreecommitdiff
path: root/tests/compare/compress.php
diff options
context:
space:
mode:
authorGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-12 07:16:23 +0200
committerGeorge Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2023-03-12 07:16:23 +0200
commit7076343338ae3439f3c86f01144818abe8c31978 (patch)
tree794abb1e6b8f821091fd095341885496b6dad51d /tests/compare/compress.php
parent47cbb529f5723b246125ae083a193e11481b89ef (diff)
downloadclassroom-7076343338ae3439f3c86f01144818abe8c31978.tar.gz
classroom-7076343338ae3439f3c86f01144818abe8c31978.tar.bz2
classroom-7076343338ae3439f3c86f01144818abe8c31978.zip
add container helpers; constuct public directory-tree
Diffstat (limited to 'tests/compare/compress.php')
-rw-r--r--tests/compare/compress.php80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/compare/compress.php b/tests/compare/compress.php
new file mode 100644
index 0000000..74fdea1
--- /dev/null
+++ b/tests/compare/compress.php
@@ -0,0 +1,80 @@
+<?php
+
+echo "test started... ";
+ob_flush();
+
+Benchmark::add_spot('query-10000-products');
+$db = Registry::use('database');
+$products = $db->runQuery("SELECT * FROM products LIMIT 10000",[]);
+
+
+
+$originalLength = $compressLength = 0;
+Benchmark::add_spot('gzcompress(1)-10000-products');
+foreach($products as $product) {
+ $original = serialize($product);
+ $compress = gzcompress($original, 1);
+ $originalLength = strlen($original);
+ $compressLength = strlen($compress);
+}
+echo "<pre>gzcompress(1)
+compressed {$originalLength} to {$compressLength} or ";
+echo ($originalLength-$compressLength)*100/$originalLength ."%\n</n>";
+
+
+
+$originalLength = $compressLength = 0;
+Benchmark::add_spot('gzcompress(4)-10000-products');
+foreach($products as $product) {
+ $original = serialize($product);
+ $compress = gzcompress($original, 4);
+ $originalLength = strlen($original);
+ $compressLength = strlen($compress);
+}
+echo "<pre>gzcompress(4)
+compressed {$originalLength} to {$compressLength} or ";
+echo ($originalLength-$compressLength)*100/$originalLength ."%\n</n>";
+
+
+
+$originalLength = $compressLength = 0;
+Benchmark::add_spot('gzcompress(6)-10000-products');
+foreach($products as $product) {
+ $original = serialize($product);
+ $compress = gzcompress($original, 6);
+ $originalLength = strlen($original);
+ $compressLength = strlen($compress);
+}
+echo "<pre>gzcompress(6)
+compressed {$originalLength} to {$compressLength} or ";
+echo ($originalLength-$compressLength)*100/$originalLength ."%\n</n>";
+
+
+
+$cache = Registry::use('cache');
+
+Benchmark::add_spot('Cache-save-10000-products');
+foreach($products as $product) {
+ $cache->set('cache.sav.'.$product['ID'], serialize($product), 3600);
+}
+
+
+
+Benchmark::add_spot('gz(ser(),6)+Save-10000-products');
+foreach($products as $product) {
+ $cache->set('zx.ser.sav.'.$product['ID'], gzcompress(serialize($product), 6), 3600);
+}
+
+$maxLen = 0;
+Benchmark::add_spot('sha1(serialize())-10000-products');
+foreach($products as $product) {
+ $original = sha1(serialize($product));
+ $maxlen = $maxLen > strlen($original) ? $maxLen : strlen($original);
+}
+
+
+Benchmark::add_spot('end');
+Benchmark::render_report('code');
+
+echo "test completed!";
+die();