Verified Commit a4ecaff0 authored by nagayama15's avatar nagayama15

add jq-web benchmark script

parent 003e4498
...@@ -7,4 +7,4 @@ export-reorder/ ...@@ -7,4 +7,4 @@ export-reorder/
operand-swap/ operand-swap/
dyn/ dyn/
/bench-zlib.txt /bench-*.txt
...@@ -41,7 +41,7 @@ bench-zlib: \ ...@@ -41,7 +41,7 @@ bench-zlib: \
zlib/raw/wasm-flate: ../node_modules/wasm-flate zlib/raw/wasm-flate: ../node_modules/wasm-flate
cp -r $< $@ cp -r $< $@
# $(eval $(call embed,watermark,method)) # $(eval $(call embed_zlib,watermark,method))
define embed_zlib define embed_zlib
.PHONY: zlib/$2/$1 .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: zlib/$2/$1/bench.js zlib/$2/$1/wasm-flate/wasm_flate.js zlib/$2/$1/wasm-flate/wasm_flate_bg.wasm
...@@ -77,17 +77,20 @@ jq: \ ...@@ -77,17 +77,20 @@ jq: \
jq/function-reorder/ANebjkXMZJwaaRMM \ jq/function-reorder/ANebjkXMZJwaaRMM \
jq/export-reorder/ANebjkXMZJwaaRMM \ jq/export-reorder/ANebjkXMZJwaaRMM \
jq/operand-swap/ANebjkXMZJwaaRMM \ jq/operand-swap/ANebjkXMZJwaaRMM \
jq/dyn/ANebjkXMZJwaaRMM \
jq/function-reorder/Qg5lb3WN8a7eRFRb \ jq/function-reorder/Qg5lb3WN8a7eRFRb \
jq/export-reorder/Qg5lb3WN8a7eRFRb \ jq/export-reorder/Qg5lb3WN8a7eRFRb \
jq/operand-swap/Qg5lb3WN8a7eRFRb \ jq/operand-swap/Qg5lb3WN8a7eRFRb \
jq/dyn/Qg5lb3WN8a7eRFRb \
jq/function-reorder/oVs8OISLiQH0RXlq \ jq/function-reorder/oVs8OISLiQH0RXlq \
jq/export-reorder/oVs8OISLiQH0RXlq \ jq/export-reorder/oVs8OISLiQH0RXlq \
jq/operand-swap/oVs8OISLiQH0RXlq jq/operand-swap/oVs8OISLiQH0RXlq \
jq/dyn/oVs8OISLiQH0RXlq
jq/raw/jq-web: ../node_modules/jq-web jq/raw/jq-web: ../node_modules/jq-web
cp -r $< $@ cp -r $< $@
# $(eval $(call embed,watermark,method)) # $(eval $(call embed_jq,watermark,method))
define embed_jq define embed_jq
.PHONY: jq/$2/$1 .PHONY: jq/$2/$1
jq/$2/$1: jq/$2/$1/bench.js jq/$2/$1/large-file.json jq/$2/$1/jq-web/jq.wasm.min.js jq/$2/$1/jq-web/jq.wasm.wasm jq/$2/$1: jq/$2/$1/bench.js jq/$2/$1/large-file.json jq/$2/$1/jq-web/jq.wasm.min.js jq/$2/$1/jq-web/jq.wasm.wasm
...@@ -109,6 +112,28 @@ jq/$2/$1/jq-web/jq.wasm.wasm: jq/raw/jq-web ...@@ -109,6 +112,28 @@ jq/$2/$1/jq-web/jq.wasm.wasm: jq/raw/jq-web
snpi -m $2 -w $1 -o $$@ $$</jq.wasm.wasm snpi -m $2 -w $1 -o $$@ $$</jq.wasm.wasm
endef endef
# $(eval $(call embed_jq_m4,watermark))
define embed_jq_m4
.PHONY: jq/dyn/$1
jq/dyn/$1: jq/dyn/$1/bench.js jq/dyn/$1/large-file.json jq/dyn/$1/jq-web/jq.wasm.min.js jq/dyn/$1/jq-web/jq.wasm.wasm
jq/dyn/$1/bench.js: jq/raw/bench.js
mkdir -p $${@D}
cp $$< $$@
jq/dyn/$1/large-file.json: jq/raw/large-file.json
mkdir -p $${@D}
cp $$< $$@
jq/dyn/$1/jq-web/jq.wasm.min.js: jq/raw/jq-web
mkdir -p $${@D}
cp $$</jq.wasm.min.js $$@
jq/dyn/$1/jq-web/jq.wasm.wasm: jq/raw/jq-web
mkdir -p $${@D}
kyuk -w $1 -o $$@ $$</jq.wasm.wasm
endef
$(eval $(call embed_jq,ANebjkXMZJwaaRMM,function-reorder)) $(eval $(call embed_jq,ANebjkXMZJwaaRMM,function-reorder))
$(eval $(call embed_jq,ANebjkXMZJwaaRMM,export-reorder)) $(eval $(call embed_jq,ANebjkXMZJwaaRMM,export-reorder))
$(eval $(call embed_jq,ANebjkXMZJwaaRMM,operand-swap)) $(eval $(call embed_jq,ANebjkXMZJwaaRMM,operand-swap))
...@@ -120,3 +145,37 @@ $(eval $(call embed_jq,Qg5lb3WN8a7eRFRb,operand-swap)) ...@@ -120,3 +145,37 @@ $(eval $(call embed_jq,Qg5lb3WN8a7eRFRb,operand-swap))
$(eval $(call embed_jq,oVs8OISLiQH0RXlq,function-reorder)) $(eval $(call embed_jq,oVs8OISLiQH0RXlq,function-reorder))
$(eval $(call embed_jq,oVs8OISLiQH0RXlq,export-reorder)) $(eval $(call embed_jq,oVs8OISLiQH0RXlq,export-reorder))
$(eval $(call embed_jq,oVs8OISLiQH0RXlq,operand-swap)) $(eval $(call embed_jq,oVs8OISLiQH0RXlq,operand-swap))
$(eval $(call embed_jq_m4,ANebjkXMZJwaaRMM))
$(eval $(call embed_jq_m4,Qg5lb3WN8a7eRFRb))
$(eval $(call embed_jq_m4,oVs8OISLiQH0RXlq))
.PHONY: bench-jq
bench-jq: \
jq/raw/jq-web \
jq/function-reorder/ANebjkXMZJwaaRMM \
jq/export-reorder/ANebjkXMZJwaaRMM \
jq/operand-swap/ANebjkXMZJwaaRMM \
jq/dyn/ANebjkXMZJwaaRMM \
jq/function-reorder/Qg5lb3WN8a7eRFRb \
jq/export-reorder/Qg5lb3WN8a7eRFRb \
jq/operand-swap/Qg5lb3WN8a7eRFRb \
jq/dyn/Qg5lb3WN8a7eRFRb \
jq/function-reorder/oVs8OISLiQH0RXlq \
jq/export-reorder/oVs8OISLiQH0RXlq \
jq/operand-swap/oVs8OISLiQH0RXlq \
jq/dyn/oVs8OISLiQH0RXlq
node jq/raw/bench.js | tee bench-jq.txt
node jq/function-reorder/ANebjkXMZJwaaRMM/bench.js | tee -a bench-jq.txt
node jq/export-reorder/ANebjkXMZJwaaRMM/bench.js | tee -a bench-jq.txt
node jq/operand-swap/ANebjkXMZJwaaRMM/bench.js | tee -a bench-jq.txt
node jq/dyn/ANebjkXMZJwaaRMM/bench.js | tee -a bench-jq.txt
node jq/function-reorder/Qg5lb3WN8a7eRFRb/bench.js | tee -a bench-jq.txt
node jq/export-reorder/Qg5lb3WN8a7eRFRb/bench.js | tee -a bench-jq.txt
node jq/operand-swap/Qg5lb3WN8a7eRFRb/bench.js | tee -a bench-jq.txt
node jq/dyn/Qg5lb3WN8a7eRFRb/bench.js | tee -a bench-jq.txt
node jq/function-reorder/oVs8OISLiQH0RXlq/bench.js | tee -a bench-jq.txt
node jq/export-reorder/oVs8OISLiQH0RXlq/bench.js | tee -a bench-jq.txt
node jq/operand-swap/oVs8OISLiQH0RXlq/bench.js | tee -a bench-jq.txt
node jq/dyn/oVs8OISLiQH0RXlq/bench.js | tee -a bench-jq.txt
...@@ -4,10 +4,24 @@ const jq = require(`${__dirname}/jq-web/jq.wasm.min.js`); ...@@ -4,10 +4,24 @@ const jq = require(`${__dirname}/jq-web/jq.wasm.min.js`);
const testData = fs.readFileSync(`${__dirname}/large-file.json`).toString(); const testData = fs.readFileSync(`${__dirname}/large-file.json`).toString();
const query = '.[5000].payload.commits | map(.message) | join("\\n")'; const query = '.[5000].payload.commits | map(.message) | join("\\n")';
const expected = '"tdiary: fix nginx configuration (use try_files, alias, and named location)\\nfluentd-ui: fix nginx configuration (use try_files, alias, and named location)\\ngeminabox: fix nginx configuration (use try_files, alias, and named location)\\nMerge branch \'master\' into fix/nginx-configs\\nMerge branch \'master\' into fix/nginx-configs\\ndebian: updated README.md\\nMerge pull request #11 from minimum2scp/fix/nginx-configs\\n\\nFixed nginx configurations for some images (use try_files, alias, and named locattions)\\nMerge branch \'master\' into feature/es-kibana4"'; const expected = '"tdiary: fix nginx configuration (use try_files, alias, and named location)\\nfluentd-ui: fix nginx configuration (use try_files, alias, and named location)\\ngeminabox: fix nginx configuration (use try_files, alias, and named location)\\nMerge branch \'master\' into fix/nginx-configs\\nMerge branch \'master\' into fix/nginx-configs\\ndebian: updated README.md\\nMerge pull request #11 from minimum2scp/fix/nginx-configs\\n\\nFixed nginx configurations for some images (use try_files, alias, and named locattions)\\nMerge branch \'master\' into feature/es-kibana4"';
jq.onInitialized.addListener(() => { jq.onInitialized.addListener(() => {
// Check if jq-web works properly // Check if jq-web works properly
assert.equal(jq.raw(testData, query), expected); assert.equal(jq.raw(testData, query), expected);
// Warm up
jq.raw(testData, query);
jq.raw(testData, query);
jq.raw(testData, query);
const count = 100;
const start = Date.now();
for (let i = 0; i < count; i++) {
jq.raw(testData, query);
}
const end = Date.now();
const duration_ms = end - start;
console.log(`${__dirname}\t${duration_ms / count}`);
}); });
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