Browse Source

Perf test updates for hex enc/dec fast path

pull/467/head
Sami Vaarala 9 years ago
parent
commit
ced0e83d58
  1. 2
      tests/perf/test-hex-encode.js
  2. 2
      tests/perf/test-hex-encode.py
  3. 35
      tests/perf/test-json-fake-message.js

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

@ -18,7 +18,7 @@ function test() {
print(tmp2.length);
print('run');
for (i = 0; i < 10000; i++) {
for (i = 0; i < 5000; i++) {
Duktape.enc('hex', tmp2);
}
}

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

@ -15,7 +15,7 @@ def test():
print(len(tmp2))
print('run')
for i in xrange(10000):
for i in xrange(5000):
ign = tmp2.encode('hex')
test()

35
tests/perf/test-json-fake-message.js

@ -0,0 +1,35 @@
/*
* Simulate creation and JSON serialization of a fake JSONRPC message.
*/
function test() {
var i;
var msg;
var bytes;
var ign;
bytes = Duktape.Buffer(4096);
for (i = 0; i < bytes.length; i++) {
bytes[i] = i;
}
for (i = 0; i < 1e5; i++) {
msg = {
jsonrpc: '2.0',
id: 'dummy',
method: 'FakeMethod',
params: {
client: 'dummy client',
timestamp: Date.now(),
data: Duktape.enc('base64', bytes)
}
};
ign = JSON.stringify(msg);
}
print(ign);
}
try {
test();
} catch (e) {
print(e.stack || e);
throw e;
}
Loading…
Cancel
Save