Skip to content

Commit

Permalink
added perf
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJDufour committed May 21, 2023
1 parent 138f0e5 commit bdcc7d4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
decode: require("./decode"),
encode: require("./encode")
decode: require("./decode.js"),
encode: require("./encode.js")
};
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"version": "0.0.1",
"description": "Fast Run Length Encoder and Decoder",
"main": "index.js",
"files": [
"index.js",
"encode.js",
"decode.js"
],
"scripts": {
"format": "npx prettier --arrow-parens=avoid --trailing-comma=none --write *.js",
"test": "node test"
Expand Down
9 changes: 8 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const test = require("flug");
const decode = require("./decode");
const encode = require("./encode");
const encode = require("./encode.js");

const decoded = [3, 3, 3, 3, 3, 8, 0, 0];
const encoded = [5, 3, 1, 8, 2, 0];
Expand Down Expand Up @@ -30,3 +30,10 @@ test("encoded with chunking", ({ eq }) => {
const actual = encode(decoded, { chunk: true });
eq(actual, chunked);
});

const len = 10_000_000;
const nums = new Uint8Array(len);
for (let i = 0; i <= len; i++) nums[i] = Math.round(Math.random() * 3);
test("perf", ({ eq }) => {
encode(nums);
});

0 comments on commit bdcc7d4

Please sign in to comment.