-
Notifications
You must be signed in to change notification settings - Fork 31
/
core-estimator.min.js
2 lines (2 loc) · 3.76 KB
/
core-estimator.min.js
1
2
/*! @source https://github.com/oftn/core-estimator/blob/master/core-estimator.js */
"use strict";(function(j){var m=20;var e=4194304;var s=navigator.hardwareConcurrency;var w=document;var n=(w.currentScript||w.scripts[w.scripts.length-1]).src.replace(/\/[^\/]+$/,"/");if(!s&&navigator.mimeTypes["application/x-pnacl"]){var r="http://www.w3.org/1999/xhtml";var k=console.error.bind(console);var l=[];var p=function(z){var x=navigator.hardwareConcurrency=z.data;var y;navigator.getHardwareConcurrency=function(B,A){B(x);if(A&&A.progress){A.progress(x,x,x)}};while(y=l.shift()){navigator.getHardwareConcurrency(y[0],y[1])}q.removeEventListener("load",g,true);q.removeEventListener("message",p,true);q.removeEventListener("error",k,true);q.removeEventListener("crash",k,true);w.documentElement.removeChild(q)};var g=function(){a.postMessage(0)};navigator.getHardwareConcurrency=function(y,x){l.push([y,x])};var q=w.createElementNS(r,"div");q.addEventListener("load",g,true);q.addEventListener("message",p,true);q.addEventListener("error",k,true);q.addEventListener("crash",k,true);var a=w.createElementNS(r,"embed");a.setAttribute("path",n+"nacl_module/pnacl/Release");a.setAttribute("src",n+"nacl_module/pnacl/Release/cores.nmf");a.setAttribute("type","application/x-pnacl");q.appendChild(a);w.documentElement.appendChild(q);return}var i=j.performance||Date;if(!i.now){if(i.webkitNow){i.now=i.webkitNow}else{i.now=function(){return +new Date}}}var o=n+"workload.js";var h=false;if(!s){navigator.hardwareConcurrency=1;if(typeof Worker==="undefined"){s=true}}navigator.getHardwareConcurrency=function(C,y){y=y||{};if(!("use_cache" in y)){y.use_cache=true}if(s||(y.use_cache&&h)){C(navigator.hardwareConcurrency);return}w.documentElement.style.cursor="progress";var x=[];var A=1;var B;var z=[];f(function(E,D){c(x,E,m,function(I){if(E===1){Array.prototype.push.apply(z,I);B=b(z);D(true)}else{var K=b(I);var H=K.uvariance/K.size;var J=B.uvariance/B.size;var G=(K.mean-B.mean)/Math.sqrt(H+J);var F=Math.pow(H+J,2)/(Math.pow(K.uvariance,2)/(Math.pow(K.size,2)*(K.size-1))+Math.pow(B.uvariance,2)/(Math.pow(B.size,2)*(B.size-1)));D(d(G,F))}})},function(E){for(var F=0,D=x.length;F<D;F++){x[F].terminate()}w.documentElement.style.cursor="";navigator.hardwareConcurrency=E;h=true;C(E)},y.progress)};function c(x,B,A,C){var y=[];for(var z=x.length;z<B;z++){x.push(new Worker(o))}v(function(D){var F,G=B;for(var E=0;E<B;E++){x[E].onmessage=function(){G--;if(!G){A--;y.push(i.now()-F);if(A){D()}else{C(y)}}}}for(var E=0;E<B;E++){x[E].postMessage(e)}F=i.now()})}function v(x){(function y(){x(y)}())}function f(D,C,y){var A=1,x=1/0;(function B(E){if(y){y(A,x,E)}D(1,function(){D(E,function(F){if(F){A=E;B(2*E)}else{x=E;if(A===1){return C(A)}z(A*3/2,A/4)}})})}(2));function z(E,F){if(y){y(A,x,E)}D(1,function(){D(E,function(G){if(G){A=E;E+=F}else{x=E;E-=F}if(x-A===1){return C(A)}if(!F){return C(x-1)}z(E,F>>1)})})}}function b(B){var F=B.length;if(!F){return null}var A=1/0,G=-1/0;var E=0;var H=0;for(var C=0;C<F;C++){var I=B[C];if(I<A){A=I}if(I>G){G=I}E+=I;H+=Math.pow(I,2)}var J=E/F;var z=Math.pow(J,2);var y=0;var x=0;if(F>1){y=H/F-z;x=(H-F*z)/(F-1)}var D={size:F,mean:J,uvariance:x};return D}var t={1:63.66,2:9.925,3:5.841,4:4.604,5:4.032,6:3.707,7:3.499,8:3.355,9:3.25,10:3.169,11:3.106,12:3.055,13:3.012,14:2.977,15:2.947,16:2.921,17:2.898,18:2.878,19:2.861,20:2.845,21:2.831,22:2.819,23:2.807,24:2.797,25:2.787,26:2.779,27:2.771,28:2.763,29:2.756,30:2.75,32:2.738,34:2.728,36:2.719,38:2.712,40:2.704,42:2.698,44:2.692,46:2.687,48:2.682,50:2.678,55:2.668,60:2.66,65:2.654,70:2.648,80:2.639,100:2.626,150:2.609,200:2.601};function d(A,y){var C=Object.keys(t);var B=C.reduce(function(E,F){if(y<F){return E}return F});var x=C.reduce(function(E,F){if(y>F){return E}return F});var z=x-B;var D=u(t[B],t[x],(y-B)/z);return A<D}function u(y,x,z){return y+(x-y)*z}}(self));