Verified Commit b0ae1b9b authored by nagayama15's avatar nagayama15

add benchmark script

parent 4991bb69
!Makefile
wasm-flate/
function-reorder/
export-reorder/
operand-swap/
dyn/
/bench-zlib.txt
.PHONY: all
all: \
zlib/function-reorder/ANebjkXMZJwaaRMM \
zlib/export-reorder/ANebjkXMZJwaaRMM \
zlib/operand-swap/ANebjkXMZJwaaRMM \
zlib/function-reorder/Qg5lb3WN8a7eRFRb \
zlib/export-reorder/Qg5lb3WN8a7eRFRb \
zlib/operand-swap/Qg5lb3WN8a7eRFRb \
zlib/function-reorder/oVs8OISLiQH0RXlq \
zlib/export-reorder/oVs8OISLiQH0RXlq \
zlib/operand-swap/oVs8OISLiQH0RXlq
.PHONY: bench-zlib
bench-zlib: \
zlib/raw/wasm-flate \
zlib/function-reorder/ANebjkXMZJwaaRMM \
zlib/export-reorder/ANebjkXMZJwaaRMM \
zlib/operand-swap/ANebjkXMZJwaaRMM \
zlib/function-reorder/Qg5lb3WN8a7eRFRb \
zlib/export-reorder/Qg5lb3WN8a7eRFRb \
zlib/operand-swap/Qg5lb3WN8a7eRFRb \
zlib/function-reorder/oVs8OISLiQH0RXlq \
zlib/export-reorder/oVs8OISLiQH0RXlq \
zlib/operand-swap/oVs8OISLiQH0RXlq
node zlib/raw/bench.js | tee bench-zlib.txt
node zlib/function-reorder/ANebjkXMZJwaaRMM/bench.js | tee -a bench-zlib.txt
node zlib/export-reorder/ANebjkXMZJwaaRMM/bench.js | tee -a bench-zlib.txt
node zlib/operand-swap/ANebjkXMZJwaaRMM/bench.js | tee -a bench-zlib.txt
node zlib/function-reorder/Qg5lb3WN8a7eRFRb/bench.js | tee -a bench-zlib.txt
node zlib/export-reorder/Qg5lb3WN8a7eRFRb/bench.js | tee -a bench-zlib.txt
node zlib/operand-swap/Qg5lb3WN8a7eRFRb/bench.js | tee -a bench-zlib.txt
node zlib/function-reorder/oVs8OISLiQH0RXlq/bench.js | tee -a bench-zlib.txt
node zlib/export-reorder/oVs8OISLiQH0RXlq/bench.js | tee -a bench-zlib.txt
node zlib/operand-swap/oVs8OISLiQH0RXlq/bench.js | tee -a bench-zlib.txt
zlib/raw/wasm-flate: ../node_modules/wasm-flate
cp -r $< $@
# $(eval $(call embed,watermark,method))
define embed
.PHONY: zlib/$2/$1
zlib/$2/$1: zlib/$2/$1/bench.js zlib/$2/$1/wasm-flate/wasm_flate.js zlib/$2/$1/wasm-flate/wasm_flate_bg.wasm
zlib/$2/$1/bench.js: zlib/raw/bench.js
mkdir -p $${@D}
cp $$< $$@
zlib/$2/$1/wasm-flate/wasm_flate.js: zlib/raw/wasm-flate
mkdir -p $${@D}
cp $$</wasm_flate.js $$@
zlib/$2/$1/wasm-flate/wasm_flate_bg.wasm: zlib/raw/wasm-flate
mkdir -p $${@D}
snpi -m $2 -w $1 -o $$@ $$</wasm_flate_bg.wasm
endef
$(eval $(call embed,ANebjkXMZJwaaRMM,function-reorder))
$(eval $(call embed,ANebjkXMZJwaaRMM,export-reorder))
$(eval $(call embed,ANebjkXMZJwaaRMM,operand-swap))
$(eval $(call embed,Qg5lb3WN8a7eRFRb,function-reorder))
$(eval $(call embed,Qg5lb3WN8a7eRFRb,export-reorder))
$(eval $(call embed,Qg5lb3WN8a7eRFRb,operand-swap))
$(eval $(call embed,oVs8OISLiQH0RXlq,function-reorder))
$(eval $(call embed,oVs8OISLiQH0RXlq,export-reorder))
$(eval $(call embed,oVs8OISLiQH0RXlq,operand-swap))
(async function() {
const Crypto = require('crypto');
const assert = require('assert');
const fs = require('fs').promises;
// Generate random bytes
const size = 2_000_000;
const rawData = new Uint8Array(Crypto.randomBytes(size));
// Initialize wasm-flate
globalThis.self = globalThis;
const wasm = await WebAssembly.compile(await fs.readFile(`${__dirname}/wasm-flate/wasm_flate_bg.wasm`));
require(`${__dirname}/wasm-flate/wasm_flate.js`);
const flate = globalThis.wasm_bindgen;
await flate(wasm);
// Check if wasm-flate work properly
const compressed = flate.deflate_encode_raw(rawData);
assert.deepEqual(flate.deflate_decode_raw(compressed), rawData);
// Warm up
flate.deflate_encode_raw(rawData);
flate.deflate_encode_raw(rawData);
flate.deflate_encode_raw(rawData);
const count = 100;
const start = Date.now();
for (let i = 0; i < count; i++) {
flate.deflate_encode_raw(rawData);
}
const end = Date.now();
const duration_ms = end - start;
console.log(`${__dirname}\t${duration_ms / count}`);
})();
...@@ -8,16 +8,299 @@ ...@@ -8,16 +8,299 @@
"version": "github:kripken/ammo.js#a4bec933859e452acd2c18e4152ac2a6a95e806f", "version": "github:kripken/ammo.js#a4bec933859e452acd2c18e4152ac2a6a95e806f",
"from": "github:kripken/ammo.js" "from": "github:kripken/ammo.js"
}, },
"array-filter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/array-filter/-/array-filter-1.0.0.tgz",
"integrity": "sha1-uveeYubvTCpMC4MSMtr/7CUfnYM=",
"dev": true
},
"assert": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/assert/-/assert-2.0.0.tgz",
"integrity": "sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A==",
"dev": true,
"requires": {
"es6-object-assign": "^1.1.0",
"is-nan": "^1.2.1",
"object-is": "^1.0.1",
"util": "^0.12.0"
}
},
"available-typed-arrays": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz",
"integrity": "sha512-XWX3OX8Onv97LMk/ftVyBibpGwY5a8SmuxZPzeOxqmuEqUCOM9ZE+uIaD1VNJ5QnvU2UQusvmKbuM1FR8QWGfQ==",
"dev": true,
"requires": {
"array-filter": "^1.0.0"
}
},
"call-bind": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
"integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
"dev": true,
"requires": {
"function-bind": "^1.1.1",
"get-intrinsic": "^1.0.2"
}
},
"crypto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
"integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==",
"dev": true
},
"define-properties": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz",
"integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==",
"dev": true,
"requires": {
"object-keys": "^1.0.12"
}
},
"es-abstract": {
"version": "1.18.0-next.2",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.2.tgz",
"integrity": "sha512-Ih4ZMFHEtZupnUh6497zEL4y2+w8+1ljnCyaTa+adcoafI1GOvMwFlDjBLfWR7y9VLfrjRJe9ocuHY1PSR9jjw==",
"dev": true,
"requires": {
"call-bind": "^1.0.2",
"es-to-primitive": "^1.2.1",
"function-bind": "^1.1.1",
"get-intrinsic": "^1.0.2",
"has": "^1.0.3",
"has-symbols": "^1.0.1",
"is-callable": "^1.2.2",
"is-negative-zero": "^2.0.1",
"is-regex": "^1.1.1",
"object-inspect": "^1.9.0",
"object-keys": "^1.1.1",
"object.assign": "^4.1.2",
"string.prototype.trimend": "^1.0.3",
"string.prototype.trimstart": "^1.0.3"
}
},
"es-to-primitive": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz",
"integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==",
"dev": true,
"requires": {
"is-callable": "^1.1.4",
"is-date-object": "^1.0.1",
"is-symbol": "^1.0.2"
}
},
"es6-object-assign": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz",
"integrity": "sha1-wsNYJlYkfDnqEHyx5mUrb58kUjw=",
"dev": true
},
"foreach": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz",
"integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=",
"dev": true
},
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
"dev": true
},
"get-intrinsic": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.0.2.tgz",
"integrity": "sha512-aeX0vrFm21ILl3+JpFFRNe9aUvp6VFZb2/CTbgLb8j75kOhvoNYjt9d8KA/tJG4gSo8nzEDedRl0h7vDmBYRVg==",
"dev": true,
"requires": {
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.1"
}
},
"has": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
"dev": true,
"requires": {
"function-bind": "^1.1.1"
}
},
"has-symbols": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz",
"integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==",
"dev": true
},
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true
},
"is-arguments": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.0.tgz",
"integrity": "sha512-1Ij4lOMPl/xB5kBDn7I+b2ttPMKa8szhEIrXDuXQD/oe3HJLTLhqhgGspwgyGd6MOywBUqVvYicF72lkgDnIHg==",
"dev": true,
"requires": {
"call-bind": "^1.0.0"
}
},
"is-callable": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.2.tgz",
"integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==",
"dev": true
},
"is-date-object": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz",
"integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==",
"dev": true
},
"is-generator-function": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.8.tgz",
"integrity": "sha512-2Omr/twNtufVZFr1GhxjOMFPAj2sjc/dKaIqBhvo4qciXfJmITGH6ZGd8eZYNHza8t1y0e01AuqRhJwfWp26WQ==",
"dev": true
},
"is-nan": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz",
"integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==",
"dev": true,
"requires": {
"call-bind": "^1.0.0",
"define-properties": "^1.1.3"
}
},
"is-negative-zero": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.1.tgz",
"integrity": "sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w==",
"dev": true
},
"is-regex": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.1.tgz",
"integrity": "sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg==",
"dev": true,
"requires": {
"has-symbols": "^1.0.1"
}
},
"is-symbol": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz",
"integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==",
"dev": true,
"requires": {
"has-symbols": "^1.0.1"
}
},
"is-typed-array": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.4.tgz",
"integrity": "sha512-ILaRgn4zaSrVNXNGtON6iFNotXW3hAPF3+0fB1usg2jFlWqo5fEDdmJkz0zBfoi7Dgskr8Khi2xZ8cXqZEfXNA==",
"dev": true,
"requires": {
"available-typed-arrays": "^1.0.2",
"call-bind": "^1.0.0",
"es-abstract": "^1.18.0-next.1",
"foreach": "^2.0.5",
"has-symbols": "^1.0.1"
}
},
"jq-web": { "jq-web": {
"version": "0.5.1", "version": "0.5.1",
"resolved": "https://registry.npmjs.org/jq-web/-/jq-web-0.5.1.tgz", "resolved": "https://registry.npmjs.org/jq-web/-/jq-web-0.5.1.tgz",
"integrity": "sha512-3Fa3E6g3U1O1j46ljy0EM10yRr4txzILga8J7bqOG8F89gZ6Lilz82WG9z6TItWpYEO0YGa4W8yFGj+NMM1xqQ==" "integrity": "sha512-3Fa3E6g3U1O1j46ljy0EM10yRr4txzILga8J7bqOG8F89gZ6Lilz82WG9z6TItWpYEO0YGa4W8yFGj+NMM1xqQ=="
}, },
"object-inspect": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.9.0.tgz",
"integrity": "sha512-i3Bp9iTqwhaLZBxGkRfo5ZbE07BQRT7MGu8+nNgwW9ItGp1TzCTw2DLEoWwjClxBjOFI/hWljTAmYGCEwmtnOw==",
"dev": true
},
"object-is": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.4.tgz",
"integrity": "sha512-1ZvAZ4wlF7IyPVOcE1Omikt7UpaFlOQq0HlSti+ZvDH3UiD2brwGMwDbyV43jao2bKJ+4+WdPJHSd7kgzKYVqg==",
"dev": true,
"requires": {
"call-bind": "^1.0.0",
"define-properties": "^1.1.3"
}
},
"object-keys": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
"dev": true
},
"object.assign": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz",
"integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==",
"dev": true,
"requires": {
"call-bind": "^1.0.0",
"define-properties": "^1.1.3",
"has-symbols": "^1.0.1",
"object-keys": "^1.1.1"
}
},
"safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"dev": true
},
"source-map": { "source-map": {
"version": "0.7.3", "version": "0.7.3",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz",
"integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==" "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ=="
}, },
"string.prototype.trimend": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.3.tgz",
"integrity": "sha512-ayH0pB+uf0U28CtjlLvL7NaohvR1amUvVZk+y3DYb0Ey2PUV5zPkkKy9+U1ndVEIXO8hNg18eIv9Jntbii+dKw==",
"dev": true,
"requires": {
"call-bind": "^1.0.0",
"define-properties": "^1.1.3"
}
},
"string.prototype.trimstart": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.3.tgz",
"integrity": "sha512-oBIBUy5lea5tt0ovtOFiEQaBkoBBkyJhZXzJYrSmDo5IUUqbOPvVezuRs/agBIdZ2p2Eo1FD6bD9USyBLfl3xg==",
"dev": true,
"requires": {
"call-bind": "^1.0.0",
"define-properties": "^1.1.3"
}
},
"util": {
"version": "0.12.3",
"resolved": "https://registry.npmjs.org/util/-/util-0.12.3.tgz",
"integrity": "sha512-I8XkoQwE+fPQEhy9v012V+TSdH2kp9ts29i20TaaDUXsg7x/onePbhFJUExBfv/2ay1ZOp/Vsm3nDlmnFGSAog==",
"dev": true,
"requires": {
"inherits": "^2.0.3",
"is-arguments": "^1.0.4",
"is-generator-function": "^1.0.7",
"is-typed-array": "^1.1.3",
"safe-buffer": "^5.1.2",
"which-typed-array": "^1.1.2"
}
},
"vim-wasm": { "vim-wasm": {
"version": "0.0.13", "version": "0.0.13",
"resolved": "https://registry.npmjs.org/vim-wasm/-/vim-wasm-0.0.13.tgz", "resolved": "https://registry.npmjs.org/vim-wasm/-/vim-wasm-0.0.13.tgz",
...@@ -27,6 +310,21 @@ ...@@ -27,6 +310,21 @@
"version": "1.0.2-browser", "version": "1.0.2-browser",
"resolved": "https://registry.npmjs.org/wasm-flate/-/wasm-flate-1.0.2-browser.tgz", "resolved": "https://registry.npmjs.org/wasm-flate/-/wasm-flate-1.0.2-browser.tgz",
"integrity": "sha512-qpqOzvbKtgG/2Mb0DYXVPQ2nOrkKYoAQtpr4QZzgO8SMfKieeODUy2vomMnimQjH/K2RGWnw+kZmO8yf+Yh9qA==" "integrity": "sha512-qpqOzvbKtgG/2Mb0DYXVPQ2nOrkKYoAQtpr4QZzgO8SMfKieeODUy2vomMnimQjH/K2RGWnw+kZmO8yf+Yh9qA=="
},
"which-typed-array": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.4.tgz",
"integrity": "sha512-49E0SpUe90cjpoc7BOJwyPHRqSAd12c10Qm2amdEZrJPCY2NDxaW01zHITrem+rnETY3dwrbH3UUrUwagfCYDA==",
"dev": true,
"requires": {
"available-typed-arrays": "^1.0.2",
"call-bind": "^1.0.0",
"es-abstract": "^1.18.0-next.1",
"foreach": "^2.0.5",
"function-bind": "^1.1.1",
"has-symbols": "^1.0.1",
"is-typed-array": "^1.1.3"
}
} }
} }
} }
...@@ -15,5 +15,9 @@ ...@@ -15,5 +15,9 @@
"source-map": "^0.7.3", "source-map": "^0.7.3",
"vim-wasm": "0.0.13", "vim-wasm": "0.0.13",
"wasm-flate": "^1.0.2-browser" "wasm-flate": "^1.0.2-browser"
},
"devDependencies": {
"assert": "^2.0.0",
"crypto": "^1.0.1"
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment