Browse Source

Perf test improvements for hex encode/decode

pull/471/head
Sami Vaarala 9 years ago
parent
commit
3a5f26335c
  1. 2
      tests/perf/test-hex-encode.js
  2. 36
      tests/perf/test-json-parse-hex.js
  3. 0
      tests/perf/test-json-parse-integer.js
  4. 0
      tests/perf/test-json-parse-integer.py
  5. 0
      tests/perf/test-json-parse-number.js
  6. 0
      tests/perf/test-json-parse-number.py
  7. 0
      tests/perf/test-json-parse-string.js
  8. 35
      tests/perf/test-json-serialize-hex.js
  9. 0
      tests/perf/test-json-serialize-jsonrpc-message.js

2
tests/perf/test-hex-encode.js

@ -21,7 +21,7 @@ function test() {
for (i = 0; i < 5000; i++) {
// Assigning to 'res' avoids garbage collection of result; this is
// intentional to avoid mixing string intern performance to the test.
res = Duktape.enc('hex', tmp2);
var res = Duktape.enc('hex', tmp2);
}
}

36
tests/perf/test-json-parse-hex.js

@ -0,0 +1,36 @@
if (typeof print !== 'function') { print = console.log; }
function test() {
var tmp1 = [];
var tmp2 = [];
var i, n, buf;
var inp1, inp2;
print('build');
buf = Duktape.Buffer(1024);
for (i = 0; i < 1024; i++) {
buf[i] = Math.random() * 256;
}
tmp1 = String(buf);
for (i = 0; i < 1024; i++) {
tmp2.push(tmp1);
}
tmp2 = Duktape.Buffer(tmp2.join(''));
print(tmp2.length);
print('run');
inp1 = Duktape.enc('jx', { foo: tmp2 });
inp2 = Duktape.enc('jx', { foox: tmp2 });
for (i = 0; i < 1000; i++) {
var res1 = Duktape.dec('jx', inp1);
var res2 = Duktape.dec('jx', inp2);
}
}
try {
test();
} catch (e) {
print(e.stack || e);
throw e;
}

0
tests/perf/test-json-integer-parse.js → tests/perf/test-json-parse-integer.js

0
tests/perf/test-json-integer-parse.py → tests/perf/test-json-parse-integer.py

0
tests/perf/test-json-number-parse.js → tests/perf/test-json-parse-number.js

0
tests/perf/test-json-number-parse.py → tests/perf/test-json-parse-number.py

0
tests/perf/test-json-string-parse.js → tests/perf/test-json-parse-string.js

35
tests/perf/test-json-serialize-hex.js

@ -0,0 +1,35 @@
if (typeof print !== 'function') { print = console.log; }
function test() {
var tmp1 = [];
var tmp2 = [];
var i, n, buf;
print('build');
buf = Duktape.Buffer(1024);
for (i = 0; i < 1024; i++) {
buf[i] = Math.random() * 256;
}
tmp1 = String(buf);
for (i = 0; i < 1024; i++) {
tmp2.push(tmp1);
}
tmp2 = Duktape.Buffer(tmp2.join(''));
print(tmp2.length);
print('run');
for (i = 0; i < 1000; i++) {
// Assigning to 'res1' and 'res2' avoids garbage collection of result;
// this is intentional to avoid mixing string intern performance to the
// test. Test both hex alignments (internal fast loop is aligned by 2).
var res1 = Duktape.enc('jx', { foo: tmp2 });
var res2 = Duktape.enc('jx', { foox: tmp2 });
}
}
try {
test();
} catch (e) {
print(e.stack || e);
throw e;
}

0
tests/perf/test-json-fake-message.js → tests/perf/test-json-serialize-jsonrpc-message.js

Loading…
Cancel
Save