1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 18:15:18 -07:00

Wasm: add basic benchmark

Not really fair yet since the script isn't preloaded
This commit is contained in:
Frank Denis 2017-10-05 00:02:37 +02:00
parent f0daa92f50
commit 93e39760b9

View File

@ -42,8 +42,10 @@ function runTest(tname) {
document.getElementById('test-res').appendChild(p); document.getElementById('test-res').appendChild(p);
if (idx >= expected.length) { if (idx >= expected.length) {
if (passed) { if (passed) {
hn.appendChild(document.createTextNode(' - PASSED')); performance.measure('bench', 'bench_start', 'bench_end');
hn.className = 'passed'; let duration = performance.getEntriesByName('bench')[0].duration;
hn.appendChild(document.createTextNode(' - PASSED (time: ' + duration + ')'));
hn.className = 'passed';
} else { } else {
hn.appendChild(document.createTextNode(' - FAILED')); hn.appendChild(document.createTextNode(' - FAILED'));
hn.className = 'err'; hn.className = 'err';
@ -75,6 +77,7 @@ function runTest(tname) {
var st = document.createElement('script'); var st = document.createElement('script');
st.src = tname + '.js'; st.src = tname + '.js';
s.parentNode.insertBefore(st, s); s.parentNode.insertBefore(st, s);
performance.mask('bench_end');
} }
xhr.send(null); xhr.send(null);
} }