vendor/libsodium/test/default/index.html.tpl in rbnacl-libsodium-1.0.15.1 vs vendor/libsodium/test/default/index.html.tpl in rbnacl-libsodium-1.0.16

- old
+ new

@@ -26,13 +26,24 @@ </head> <body> <h1></h1> <section class="test" id="test-res"></section> <script> +var performance; +if (typeof performance !== 'object') { + performance = { + mark: function(s) { this[s] = new Date() }, + measure: function(_t, s1, s2) { this.t = this[s2] - this[s1] }, + getEntriesByName: function() { return [ { duration: this.t } ] } + }; +} + +var Module = { preRun: function() { performance.mark('bench_start') } }; + function runTest(tname) { var xhr, expected, hn, idx = 0, passed = true; - + function outputReceived(e) { var found = e.data; var p = document.createElement('p'); if (found !== expected[idx++]) { p.className = 'err'; @@ -40,11 +51,14 @@ } p.appendChild(document.createTextNode(found)); document.getElementById('test-res').appendChild(p); if (idx >= expected.length) { if (passed) { - hn.appendChild(document.createTextNode(' - PASSED')); - hn.className = 'passed'; + performance.mark('bench_end') + performance.measure('bench', 'bench_start', 'bench_end'); + var duration = Math.round(performance.getEntriesByName('bench')[0].duration); + hn.appendChild(document.createTextNode(' - PASSED (time: ' + duration + ' ms)')); + hn.className = 'passed'; } else { hn.appendChild(document.createTextNode(' - FAILED')); hn.className = 'err'; } }