Skip to content

Commit

Permalink
re-add slow lz4js library to conduct performance comparison on dev in…
Browse files Browse the repository at this point in the history
…stance
  • Loading branch information
philippotto committed Nov 23, 2022
1 parent 062f846 commit c86c647
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .circleci/not-on-master.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
set -Eeuo pipefail

if [ "${CIRCLE_BRANCH}" == "master" ]; then
# if [ "${CIRCLE_BRANCH}" == "master" ]; then
echo "Skipping this step on master..."
else
exec "$@"
fi
# else
# exec "$@"
# fi
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import { expose } from "./comlink_wrapper";
// @ts-expect-error ts-migrate(7016) FIXME: Could not find a declaration file for module 'lz4j... Remove this comment to see the full error message
import lz4Slow from "lz4js";
import * as lz4 from "lz4-wasm";

const useSlowCompressor = Math.random() > 0.5;
console.log("useSlowCompressor", useSlowCompressor);
function compressLz4Block(data: Uint8Array, compress: boolean): Uint8Array {
const compressor = useSlowCompressor ? lz4Slow : lz4;

const then = performance.now();
if (compress) {
return lz4.compress(data);
const retval = compressor.compress(data);
console.log(`${useSlowCompressor ? "slow" : "fast"} compress: ${performance.now() - then}`);
return retval;
}

return lz4.decompress(data);
const retval = compressor.decompress(data);
console.log(`${useSlowCompressor ? "slow" : "fast"} decompress: ${performance.now() - then}`);
return retval;
}

// This function is only exposed for slow_byte_array_lz4_compression.worker.js
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
"jszip": "^3.7.0",
"lodash": "^4.17.21",
"lz4-wasm": "^0.9.2",
"lz4js": "^0.2.0",
"memoize-one": "^6.0.0",
"mini-css-extract-plugin": "^2.5.2",
"minisearch": "^5.0.0",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8732,6 +8732,11 @@ lz4-wasm@^0.9.2:
resolved "https://registry.yarnpkg.com/lz4-wasm/-/lz4-wasm-0.9.2.tgz#2047b8a9771ad33b1699c350cda3e86249fbbb46"
integrity sha512-8Y/OvG/nTQNWR242NhLmjI7VzLMRKFaxg/+Pxi/vkczgFdrS4qiJ8l6n30XyNJyc0TB5C66Ncdjq345Kx5XsvQ==

lz4js@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/lz4js/-/lz4js-0.2.0.tgz#09f1a397cb2158f675146c3351dde85058cb322f"
integrity sha512-gY2Ia9Lm7Ep8qMiuGRhvUq0Q7qUereeldZPP1PMEJxPtEWHJLqw9pgX68oHajBH0nzJK4MaZEA/YNV3jT8u8Bg==

magic-string@^0.25.7:
version "0.25.7"
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051"
Expand Down

0 comments on commit c86c647

Please sign in to comment.