forked from developit/vhtml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bench.html
17 lines (16 loc) · 4.39 KB
/
bench.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>stringjsx benchmark</title>
</head>
<body>
<p>loading...</p>
</body>
<!-- micro-benchmark as external dependency -->
<script>
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.microBenchmark=e()}}(function(){return function e(t,n,r){function o(u,a){if(!n[u]){if(!t[u]){var f="function"==typeof require&&require;if(!a&&f)return f(u,!0);if(i)return i(u,!0);var s=new Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var p=n[u]={exports:{}};t[u][0].call(p.exports,function(e){var n=t[u][1][e];return o(n?n:e)},p,p.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t,n){function r(e,t){var n=e;return Object.keys(t||{}).forEach(function(e){n[e]=t[e]}),n}t.exports=r},{}],2:[function(e,t,n){var r=e("./profile"),o=e("./profileAsync"),i=e("./suite"),u=e("./suiteAsync"),a=e("./report"),f=e("./util");t.exports={profile:r,profileAsync:o,suite:i,suiteAsync:u,report:a,util:f}},{"./profile":3,"./profileAsync":4,"./report":5,"./suite":6,"./suiteAsync":7,"./util":8}],3:[function(e,t,n){function r(e,t){if(!(e instanceof Function))throw new Error("No function to profile!");for(var n,r,i=o({maxOperations:1e3,duration:100},t),u=Date.now(),a=0;;)if(n=e(),r=Date.now()-u,a++,r>=i.duration||a>=i.maxOperations)break;return{ops:a/r*1e3,time:r/a,lastResult:n}}var o=e("./createConfig");t.exports=r},{"./createConfig":1}],4:[function(e,t,n){function r(e,t,n){if(!(e instanceof Function))throw new Error("No function to profile!");if(!(n instanceof Function))throw new Error("No callback function!");var r,i,u=o({maxOperations:1e3,duration:100},t),a=Date.now(),f=0,s=function(t){if(r=t,i=Date.now()-a,f++,i>=u.duration||f>=u.maxOperations){var o={ops:f/i*1e3,time:i/f,lastResult:r};n(o)}else e(s)};e(s)}var o=e("./createConfig");t.exports=r},{"./createConfig":1}],5:[function(e,t,n){function r(e,t){var n=function(t){var n=u[t].length,r=e.map(o.prop(t)),i=r.map(o.prop("length")),a=o.max(i);return Math.max(n,a)},r=function(e,t){var n=i.chartWidth,r=e.original.ops/t;return isNaN(r)?n:Math.round(n*r)},i={chartWidth:30};"object"==typeof t&&Object.keys(t).forEach(function(e){i[e]=t[e]});var u={name:"Name",ops:"Operations per second",time:"Average time, ms"},a=o.max(e.map(o.prop("ops")));e=e.map(function(e){return{name:e.name,ops:o.formatNumber(e.ops),time:o.formatNumber(e.time),lastResult:e.lastResult,original:e}});var f=n("name"),s=n("ops"),p=n("time"),c="\n",l=" ",m=e.map(function(e){return[o.pad(e.name,f),o.pad(e.ops,s),o.pad(e.time,p),o.repeat("=",r(e,a))+">"].join(l)});u=[o.pad(u.name,f),o.pad(u.ops,s),o.padLeft(u.time,p)];var d=[];return d.push(u.join(l)),d.push(m.join(c)),d.join("\n")}var o=(e("./suite"),e("./util").formatNumber,e("./util"));t.exports=r},{"./suite":6,"./util":8}],6:[function(e,t,n){function r(e){var t=e.specs,n=t.map(function(t){var n=o(t.fn,e);return{name:t.name||i.uniqId("suite-"),ops:n.ops,time:n.time,lastResult:n.lastResult}});return n.sort(function(e,t){return t.ops-e.ops}),n}var o=e("./profile"),i=e("./util");t.exports=r},{"./profile":3,"./util":8}],7:[function(e,t,n){function r(e,t){var n=e.specs;!function r(n,u){var a=n.shift();a?o(a.fn,e,function(e){u.push({name:a.name||i.uniqId("suite-"),ops:e.ops,time:e.time,lastResult:e.lastResult}),r(n,u)}):t(u)}(n,[])}var o=e("./profileAsync"),i=e("./util");t.exports=r},{"./profileAsync":4,"./util":8}],8:[function(e,t,n){function r(e){if("number"!=typeof e)return e;switch(!0){case 0===e:return"0";case 1>e:return e.toFixed(2);case 1e3>e:return e.toFixed(0);default:return e.toExponential(1).replace(/e\+/," x 10^")}}function o(e,t,n){return(void 0===n||""===n)&&(n=" "),e.length<t?o(e+n,t,n):e}function i(e,t,n){return(void 0===n||""===n)&&(n=" "),e.length<t?i(n+e,t,n):e}function u(e){return function(t){return t[e]}}function a(e){return Math.max.apply(Math,e)}function f(e,t){return new Array(t+1).join(e)}function s(e){return e+String(s.counter++)}s.counter=0,s.reset=function(e){s.counter=e},t.exports={formatNumber:r,pad:o,padLeft:i,prop:u,max:a,repeat:f,uniqId:s}},{}]},{},[2])(2)});
</script>
<script src="./tmp/bench.browser.js"></script>
</html>