Comparing version 0.1.0 to 0.2.0
CHANGELOG | ||
v0.2.0 | ||
- `NodeTestDriver` renamed to `BrowserDriver` | ||
- Fixes to Log class | ||
- Fixes to build scripts | ||
@@ -4,0 +8,0 @@ v0.1.0 |
@@ -1,1 +0,2 @@ | ||
import{formatSI,rightPad}from'../utils/formatters';import{global}from'../utils/globals';import{autobind}from'../utils/autobind';import LocalStorage from'../utils/local-storage';import assert from'assert';const noop=()=>{},TIME_THRESHOLD_MS=80,TIME_COOLDOWN_MS=5,MIN_ITERATIONS=1;export const LOG_ENTRY={GROUP:'group',TEST:'test',COMPLETE:'complete'};const CALIBRATION_TESTS=[{id:'warmup',initFunc:noop,testFunc:()=>100,opts:{}}];export default class Bench{constructor({id:a,log:b,time:c=TIME_THRESHOLD_MS,delay:d=TIME_COOLDOWN_MS,minIterations:e=MIN_ITERATIONS}={}){if(!b){const a=global.probe&&global.probe.markdown;b=a?logResultsAsMarkdownTable:logResultsAsTree}this.id=a,this.opts={log:b,time:c,delay:d,minIterations:e},this.tests={},this.results={},this.table={},autobind(this),Object.seal(this)}calibrate(){return this}run(){const a=new Date,b=this.tests,c=this.onBenchmarkComplete,d=runAsyncTests({tests:b,onBenchmarkComplete:c});return d.then(()=>{const b=(new Date-a)/1e3;logEntry(this,{entry:LOG_ENTRY.COMPLETE,time:b,message:'Complete'}),this.onSuiteComplete()}),d}group(a){return assert(!this.tests[a],'tests need unique id strings'),this.tests[a]={id:a,group:!0,opts:this.opts},this}add(a,b,c,d){'string'==typeof a&&(d=c,c=b,b=a,a=0),assert(b),assert('function'==typeof c);let e=null,f=c;return'function'==typeof d&&(e=c,f=d),assert(!this.tests[b],'tests need unique id strings'),this.tests[b]={id:b,priority:a,initFunc:e,testFunc:f,opts:this.opts},this}onBenchmarkComplete({id:a,time:b,iterations:c,itersPerSecond:d}){const e=Math.round(c/b);this.table[a]={percent:'',iterations:`${d}/s`,current:e,max:''}}onSuiteComplete(){let a;try{a=new LocalStorage}catch(a){}if(a){const b=a.getObject(this.id),c=this.updateTable(this.table,b);a.setObject(this.id,c),console.table(c)}}updateTable(a,b){for(const c in this.table)if(b[c]&&b[c].max!==void 0){a[c].max=Math.max(a[c].current,b[c].max);const d=a[c].current/b[c].max;a[c].percent=`${Math.round(100*d-100)}%`}else a[c].max=a[c].current;return a}}function runCalibrationTests({tests:a}){let b=Promise.resolve(!0);for(const c of CALIBRATION_TESTS)b=b.then(()=>runAsyncTest({test:c,silent:!0}));return b}function runAsyncTests({tests:a,onBenchmarkComplete:b=noop}){let c=runCalibrationTests({tests:a,onBenchmarkComplete:b});for(const d in a){const e=a[d];c=c.then(()=>runAsyncTest({test:e,onBenchmarkComplete:b}))}return c}function runAsyncTest({test:a,onBenchmarkComplete:b,silent:c=!1}){return new Promise((d)=>{setTimeout(()=>{try{if(a.group)logEntry(a,{entry:LOG_ENTRY.GROUP,id:a.id,message:a.id});else{var e=runBenchTest(a);const d=e.time,f=e.iterations,g=f/d,h=formatSI(g);c||logEntry(a,{entry:LOG_ENTRY.TEST,id:a.id,priority:a.priority,itersPerSecond:h,time:d,message:`${a.id} ${h}/s`}),b&&b({id:a.id,time:d,iterations:f,iterationsPerSecond:g,itersPerSecond:h})}}finally{d(!0)}},a.opts.delay)})}function runBenchTest(a){let b=a.opts.minIterations/10,c=0;for(;c<a.opts.time;){let d=10;10<c&&(d=1.25*(a.opts.time/c)),b*=d;const e=new Date;runBenchTestIterations(a,b),c=new Date-e}const d=c/1e3;return{time:d,iterations:b}}function runBenchTestIterations(a,b){const c=a.initFunc&&a.initFunc(),d=a.context,e=a.testFunc;if(d&&c)for(let a=0;a<b;a++)e.call(d,c);else for(let a=0;a<b;a++)e.call(d)}function logEntry(a,b){const c=10|(global.probe&&global.probe.priority);(0|b.priority)<=c&&a.opts.log(b)}export function logResultsAsMarkdownTable({entry:a,id:b,itersPerSecond:c,time:d}){const e=50;switch(a){case LOG_ENTRY.GROUP:console.log(''),console.log(`| ${rightPad(b,e)} | iterations/s |`),console.log(`| ${rightPad('---',e)} | --- |`);break;case LOG_ENTRY.TEST:console.log(`| ${rightPad(b,e)} | ${rightPad(c,12)} |`);break;case LOG_ENTRY.COMPLETE:console.log(''),console.log(`Completed benchmark in ${d}s`);break;default:}}export function logResultsAsTree({entry:a,id:b,itersPerSecond:c,time:d}){switch(a){case LOG_ENTRY.GROUP:console.log(''),console.log(`${b}`);break;case LOG_ENTRY.TEST:console.log(`├─ ${b}: ${c} iterations/s`);break;case LOG_ENTRY.COMPLETE:console.log(''),console.log(`Completed benchmark in ${d}s`);break;default:}}export function logResultsAsTreeWithElapsed({entry:a,id:b,itersPerSecond:c,time:d}){a===LOG_ENTRY.TEST?console.log(`├─ ${b}: ${c} iterations/s (${d.toFixed(2)}s elapsed)`):logResultsAsTree({entry:a,id:b,itersPerSecond:c,time:d})} | ||
import{formatSI,rightPad}from'../lib/utils/formatters';import{global}from'../lib/utils/globals';import{autobind}from'../lib/utils/autobind';import LocalStorage from'../lib/utils/local-storage';import assert from'assert';const noop=()=>{},TIME_THRESHOLD_MS=80,TIME_COOLDOWN_MS=5,MIN_ITERATIONS=1;export const LOG_ENTRY={GROUP:'group',TEST:'test',COMPLETE:'complete'};const CALIBRATION_TESTS=[{id:'warmup',initFunc:noop,testFunc:()=>100,opts:{}}];export default class Bench{constructor({id:a,log:b,time:c=TIME_THRESHOLD_MS,delay:d=TIME_COOLDOWN_MS,minIterations:e=MIN_ITERATIONS}={}){if(!b){const a=global.probe&&global.probe.markdown;b=a?logResultsAsMarkdownTable:logResultsAsTree}this.id=a,this.opts={log:b,time:c,delay:d,minIterations:e},this.tests={},this.results={},this.table={},autobind(this),Object.seal(this)}calibrate(){return this}run(){const a=new Date,b=this.tests,c=this.onBenchmarkComplete,d=runAsyncTests({tests:b,onBenchmarkComplete:c});return d.then(()=>{const b=(new Date-a)/1e3;logEntry(this,{entry:LOG_ENTRY.COMPLETE,time:b,message:'Complete'}),this.onSuiteComplete()}),d}group(a){return assert(!this.tests[a],'tests need unique id strings'),this.tests[a]={id:a,group:!0,opts:this.opts},this}add(a,b,c,d){'string'==typeof a&&(d=c,c=b,b=a,a=0),assert(b),assert('function'==typeof c);let e=null,f=c;return'function'==typeof d&&(e=c,f=d),assert(!this.tests[b],'tests need unique id strings'),this.tests[b]={id:b,priority:a,initFunc:e,testFunc:f,opts:this.opts},this}onBenchmarkComplete({id:a,time:b,iterations:c,itersPerSecond:d}){const e=Math.round(c/b);this.table[a]={percent:'',iterations:`${d}/s`,current:e,max:''}}onSuiteComplete(){let a;try{a=new LocalStorage}catch(a){}if(a){const b=a.getObject(this.id),c=this.updateTable(this.table,b);a.setObject(this.id,c),console.table(c)}}updateTable(a,b){for(const c in this.table)if(b[c]&&b[c].max!==void 0){a[c].max=Math.max(a[c].current,b[c].max);const d=a[c].current/b[c].max;a[c].percent=`${Math.round(100*d-100)}%`}else a[c].max=a[c].current;return a}}function runCalibrationTests({tests:a}){let b=Promise.resolve(!0);for(const c of CALIBRATION_TESTS)b=b.then(()=>runAsyncTest({test:c,silent:!0}));return b}function runAsyncTests({tests:a,onBenchmarkComplete:b=noop}){let c=runCalibrationTests({tests:a,onBenchmarkComplete:b});for(const d in a){const e=a[d];c=c.then(()=>runAsyncTest({test:e,onBenchmarkComplete:b}))}return c}function runAsyncTest({test:a,onBenchmarkComplete:b,silent:c=!1}){return new Promise((d)=>{setTimeout(()=>{try{if(a.group)logEntry(a,{entry:LOG_ENTRY.GROUP,id:a.id,message:a.id});else{var e=runBenchTest(a);const d=e.time,f=e.iterations,g=f/d,h=formatSI(g);c||logEntry(a,{entry:LOG_ENTRY.TEST,id:a.id,priority:a.priority,itersPerSecond:h,time:d,message:`${a.id} ${h}/s`}),b&&b({id:a.id,time:d,iterations:f,iterationsPerSecond:g,itersPerSecond:h})}}finally{d(!0)}},a.opts.delay)})}function runBenchTest(a){let b=a.opts.minIterations/10,c=0;for(;c<a.opts.time;){let d=10;10<c&&(d=1.25*(a.opts.time/c)),b*=d;const e=new Date;runBenchTestIterations(a,b),c=new Date-e}const d=c/1e3;return{time:d,iterations:b}}function runBenchTestIterations(a,b){const c=a.initFunc&&a.initFunc(),d=a.context,e=a.testFunc;if(d&&c)for(let a=0;a<b;a++)e.call(d,c);else for(let a=0;a<b;a++)e.call(d)}function logEntry(a,b){const c=10|(global.probe&&global.probe.priority);(0|b.priority)<=c&&a.opts.log(b)}export function logResultsAsMarkdownTable({entry:a,id:b,itersPerSecond:c,time:d}){const e=50;switch(a){case LOG_ENTRY.GROUP:console.log(''),console.log(`| ${rightPad(b,e)} | iterations/s |`),console.log(`| ${rightPad('---',e)} | --- |`);break;case LOG_ENTRY.TEST:console.log(`| ${rightPad(b,e)} | ${rightPad(c,12)} |`);break;case LOG_ENTRY.COMPLETE:console.log(''),console.log(`Completed benchmark in ${d}s`);break;default:}}export function logResultsAsTree({entry:a,id:b,itersPerSecond:c,time:d}){switch(a){case LOG_ENTRY.GROUP:console.log(''),console.log(`${b}`);break;case LOG_ENTRY.TEST:console.log(`├─ ${b}: ${c} iterations/s`);break;case LOG_ENTRY.COMPLETE:console.log(''),console.log(`Completed benchmark in ${d}s`);break;default:}}export function logResultsAsTreeWithElapsed({entry:a,id:b,itersPerSecond:c,time:d}){a===LOG_ENTRY.TEST?console.log(`├─ ${b}: ${c} iterations/s (${d.toFixed(2)}s elapsed)`):logResultsAsTree({entry:a,id:b,itersPerSecond:c,time:d})} | ||
//# sourceMappingURL=bench.js.map |
@@ -1,1 +0,2 @@ | ||
export{default as Bench,LOG_ENTRY,logResultsAsMarkdownTable,logResultsAsTree,logResultsAsTreeWithElapsed}from'./bench'; | ||
export{default as Bench,LOG_ENTRY,logResultsAsMarkdownTable,logResultsAsTree,logResultsAsTreeWithElapsed}from'./bench'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,2 @@ | ||
import'./init';export{VERSION}from'./utils/globals';export{default as Log}from'./log/log';import{enableDOMLogging}from'./utils/log-to-dom';export const experimental={enableDOMLogging}; | ||
import'./init';export{VERSION}from'./lib/utils/globals';export{default as Log}from'./lib/log';import{enableDOMLogging}from'./lib/utils/log-to-dom';export const experimental={enableDOMLogging}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,2 @@ | ||
import{global}from'./utils/globals';global.probe={}; | ||
import{global}from'./lib/utils/globals';global.probe={}; | ||
//# sourceMappingURL=init.js.map |
@@ -1,1 +0,2 @@ | ||
export{makeSpy}from'./make-spy';export{default as NodeTestDriver}from'./node-test-driver'; | ||
export{makeSpy}from'./make-spy';export{default as BrowserDriver}from'./browser-driver'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,2 @@ | ||
export function makeSpy(a,b){let c;return a||b?'function'!=typeof a||b?(c=b,b=a[c]):(b=a,a={},c=`${b.name}-spy`):(b=function(){},a={},c='spy'),wrapFunction(a,b,c)}function wrapFunction(a,b,c){function d(...a){return d.callCount++,d.called=!0,b.apply(this,a)}return void 0===b.func?(Object.assign(d,{reset(){d.callCount=0,d.called=!1},restore(){a[c]=b},obj:a,methodName:c,func:b,method:b}),d.reset(),a[c]=d,d):b} | ||
export function makeSpy(a,b){let c;return a||b?'function'!=typeof a||b?(c=b,b=a[c]):(b=a,a={},c=`${b.name}-spy`):(b=function(){},a={},c='spy'),wrapFunction(a,b,c)}function wrapFunction(a,b,c){function d(...a){return d.callCount++,d.called=!0,b.apply(this,a)}return void 0===b.func?(Object.assign(d,{reset(){d.callCount=0,d.called=!1},restore(){a[c]=b},obj:a,methodName:c,func:b,method:b}),d.reset(),a[c]=d,d):b} | ||
//# sourceMappingURL=make-spy.js.map |
@@ -1,1 +0,2 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.LOG_ENTRY=void 0,exports.logResultsAsMarkdownTable=logResultsAsMarkdownTable,exports.logResultsAsTree=logResultsAsTree,exports.logResultsAsTreeWithElapsed=logResultsAsTreeWithElapsed;var _formatters=require('../utils/formatters'),_globals=require('../utils/globals'),_autobind=require('../utils/autobind'),_localStorage=require('../utils/local-storage'),_localStorage2=_interopRequireDefault(_localStorage),_assert=require('assert'),_assert2=_interopRequireDefault(_assert);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}const noop=()=>{},TIME_THRESHOLD_MS=80,TIME_COOLDOWN_MS=5,MIN_ITERATIONS=1,LOG_ENTRY=exports.LOG_ENTRY={GROUP:'group',TEST:'test',COMPLETE:'complete'},CALIBRATION_TESTS=[{id:'warmup',initFunc:noop,testFunc:()=>100,opts:{}}];class Bench{constructor({id:a,log:b,time:c=TIME_THRESHOLD_MS,delay:d=TIME_COOLDOWN_MS,minIterations:e=MIN_ITERATIONS}={}){if(!b){const a=_globals.global.probe&&_globals.global.probe.markdown;b=a?logResultsAsMarkdownTable:logResultsAsTree}this.id=a,this.opts={log:b,time:c,delay:d,minIterations:e},this.tests={},this.results={},this.table={},(0,_autobind.autobind)(this),Object.seal(this)}calibrate(){return this}run(){const a=new Date,b=this.tests,c=this.onBenchmarkComplete,d=runAsyncTests({tests:b,onBenchmarkComplete:c});return d.then(()=>{const b=(new Date-a)/1e3;logEntry(this,{entry:LOG_ENTRY.COMPLETE,time:b,message:'Complete'}),this.onSuiteComplete()}),d}group(a){return(0,_assert2.default)(!this.tests[a],'tests need unique id strings'),this.tests[a]={id:a,group:!0,opts:this.opts},this}add(a,b,c,d){'string'==typeof a&&(d=c,c=b,b=a,a=0),(0,_assert2.default)(b),(0,_assert2.default)('function'==typeof c);let e=null,f=c;return'function'==typeof d&&(e=c,f=d),(0,_assert2.default)(!this.tests[b],'tests need unique id strings'),this.tests[b]={id:b,priority:a,initFunc:e,testFunc:f,opts:this.opts},this}onBenchmarkComplete({id:a,time:b,iterations:c,itersPerSecond:d}){const e=Math.round(c/b);this.table[a]={percent:'',iterations:`${d}/s`,current:e,max:''}}onSuiteComplete(){let a;try{a=new _localStorage2.default}catch(a){}if(a){const b=a.getObject(this.id),c=this.updateTable(this.table,b);a.setObject(this.id,c),console.table(c)}}updateTable(a,b){for(const c in this.table)if(b[c]&&b[c].max!==void 0){a[c].max=Math.max(a[c].current,b[c].max);const d=a[c].current/b[c].max;a[c].percent=`${Math.round(100*d-100)}%`}else a[c].max=a[c].current;return a}}exports.default=Bench;function runCalibrationTests({tests:a}){let b=Promise.resolve(!0);for(const c of CALIBRATION_TESTS)b=b.then(()=>runAsyncTest({test:c,silent:!0}));return b}function runAsyncTests({tests:a,onBenchmarkComplete:b=noop}){let c=runCalibrationTests({tests:a,onBenchmarkComplete:b});for(const d in a){const e=a[d];c=c.then(()=>runAsyncTest({test:e,onBenchmarkComplete:b}))}return c}function runAsyncTest({test:a,onBenchmarkComplete:b,silent:c=!1}){return new Promise((d)=>{setTimeout(()=>{try{if(a.group)logEntry(a,{entry:LOG_ENTRY.GROUP,id:a.id,message:a.id});else{var e=runBenchTest(a);const d=e.time,f=e.iterations,g=f/d,h=(0,_formatters.formatSI)(g);c||logEntry(a,{entry:LOG_ENTRY.TEST,id:a.id,priority:a.priority,itersPerSecond:h,time:d,message:`${a.id} ${h}/s`}),b&&b({id:a.id,time:d,iterations:f,iterationsPerSecond:g,itersPerSecond:h})}}finally{d(!0)}},a.opts.delay)})}function runBenchTest(a){let b=a.opts.minIterations/10,c=0;for(;c<a.opts.time;){let d=10;10<c&&(d=1.25*(a.opts.time/c)),b*=d;const e=new Date;runBenchTestIterations(a,b),c=new Date-e}const d=c/1e3;return{time:d,iterations:b}}function runBenchTestIterations(a,b){const c=a.initFunc&&a.initFunc(),d=a.context,e=a.testFunc;if(d&&c)for(let a=0;a<b;a++)e.call(d,c);else for(let a=0;a<b;a++)e.call(d)}function logEntry(a,b){const c=10|(_globals.global.probe&&_globals.global.probe.priority);(0|b.priority)<=c&&a.opts.log(b)}function logResultsAsMarkdownTable({entry:a,id:b,itersPerSecond:c,time:d}){const e=50;switch(a){case LOG_ENTRY.GROUP:console.log(''),console.log(`| ${(0,_formatters.rightPad)(b,e)} | iterations/s |`),console.log(`| ${(0,_formatters.rightPad)('---',e)} | --- |`);break;case LOG_ENTRY.TEST:console.log(`| ${(0,_formatters.rightPad)(b,e)} | ${(0,_formatters.rightPad)(c,12)} |`);break;case LOG_ENTRY.COMPLETE:console.log(''),console.log(`Completed benchmark in ${d}s`);break;default:}}function logResultsAsTree({entry:a,id:b,itersPerSecond:c,time:d}){switch(a){case LOG_ENTRY.GROUP:console.log(''),console.log(`${b}`);break;case LOG_ENTRY.TEST:console.log(`├─ ${b}: ${c} iterations/s`);break;case LOG_ENTRY.COMPLETE:console.log(''),console.log(`Completed benchmark in ${d}s`);break;default:}}function logResultsAsTreeWithElapsed({entry:a,id:b,itersPerSecond:c,time:d}){a===LOG_ENTRY.TEST?console.log(`├─ ${b}: ${c} iterations/s (${d.toFixed(2)}s elapsed)`):logResultsAsTree({entry:a,id:b,itersPerSecond:c,time:d})} | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.LOG_ENTRY=void 0,exports.logResultsAsMarkdownTable=logResultsAsMarkdownTable,exports.logResultsAsTree=logResultsAsTree,exports.logResultsAsTreeWithElapsed=logResultsAsTreeWithElapsed;var _formatters=require('../lib/utils/formatters'),_globals=require('../lib/utils/globals'),_autobind=require('../lib/utils/autobind'),_localStorage=require('../lib/utils/local-storage'),_localStorage2=_interopRequireDefault(_localStorage),_assert=require('assert'),_assert2=_interopRequireDefault(_assert);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}const noop=()=>{},TIME_THRESHOLD_MS=80,TIME_COOLDOWN_MS=5,MIN_ITERATIONS=1,LOG_ENTRY=exports.LOG_ENTRY={GROUP:'group',TEST:'test',COMPLETE:'complete'},CALIBRATION_TESTS=[{id:'warmup',initFunc:noop,testFunc:()=>100,opts:{}}];class Bench{constructor({id:a,log:b,time:c=TIME_THRESHOLD_MS,delay:d=TIME_COOLDOWN_MS,minIterations:e=MIN_ITERATIONS}={}){if(!b){const a=_globals.global.probe&&_globals.global.probe.markdown;b=a?logResultsAsMarkdownTable:logResultsAsTree}this.id=a,this.opts={log:b,time:c,delay:d,minIterations:e},this.tests={},this.results={},this.table={},(0,_autobind.autobind)(this),Object.seal(this)}calibrate(){return this}run(){const a=new Date,b=this.tests,c=this.onBenchmarkComplete,d=runAsyncTests({tests:b,onBenchmarkComplete:c});return d.then(()=>{const b=(new Date-a)/1e3;logEntry(this,{entry:LOG_ENTRY.COMPLETE,time:b,message:'Complete'}),this.onSuiteComplete()}),d}group(a){return(0,_assert2.default)(!this.tests[a],'tests need unique id strings'),this.tests[a]={id:a,group:!0,opts:this.opts},this}add(a,b,c,d){'string'==typeof a&&(d=c,c=b,b=a,a=0),(0,_assert2.default)(b),(0,_assert2.default)('function'==typeof c);let e=null,f=c;return'function'==typeof d&&(e=c,f=d),(0,_assert2.default)(!this.tests[b],'tests need unique id strings'),this.tests[b]={id:b,priority:a,initFunc:e,testFunc:f,opts:this.opts},this}onBenchmarkComplete({id:a,time:b,iterations:c,itersPerSecond:d}){const e=Math.round(c/b);this.table[a]={percent:'',iterations:`${d}/s`,current:e,max:''}}onSuiteComplete(){let a;try{a=new _localStorage2.default}catch(a){}if(a){const b=a.getObject(this.id),c=this.updateTable(this.table,b);a.setObject(this.id,c),console.table(c)}}updateTable(a,b){for(const c in this.table)if(b[c]&&b[c].max!==void 0){a[c].max=Math.max(a[c].current,b[c].max);const d=a[c].current/b[c].max;a[c].percent=`${Math.round(100*d-100)}%`}else a[c].max=a[c].current;return a}}exports.default=Bench;function runCalibrationTests({tests:a}){let b=Promise.resolve(!0);for(const c of CALIBRATION_TESTS)b=b.then(()=>runAsyncTest({test:c,silent:!0}));return b}function runAsyncTests({tests:a,onBenchmarkComplete:b=noop}){let c=runCalibrationTests({tests:a,onBenchmarkComplete:b});for(const d in a){const e=a[d];c=c.then(()=>runAsyncTest({test:e,onBenchmarkComplete:b}))}return c}function runAsyncTest({test:a,onBenchmarkComplete:b,silent:c=!1}){return new Promise((d)=>{setTimeout(()=>{try{if(a.group)logEntry(a,{entry:LOG_ENTRY.GROUP,id:a.id,message:a.id});else{var e=runBenchTest(a);const d=e.time,f=e.iterations,g=f/d,h=(0,_formatters.formatSI)(g);c||logEntry(a,{entry:LOG_ENTRY.TEST,id:a.id,priority:a.priority,itersPerSecond:h,time:d,message:`${a.id} ${h}/s`}),b&&b({id:a.id,time:d,iterations:f,iterationsPerSecond:g,itersPerSecond:h})}}finally{d(!0)}},a.opts.delay)})}function runBenchTest(a){let b=a.opts.minIterations/10,c=0;for(;c<a.opts.time;){let d=10;10<c&&(d=1.25*(a.opts.time/c)),b*=d;const e=new Date;runBenchTestIterations(a,b),c=new Date-e}const d=c/1e3;return{time:d,iterations:b}}function runBenchTestIterations(a,b){const c=a.initFunc&&a.initFunc(),d=a.context,e=a.testFunc;if(d&&c)for(let a=0;a<b;a++)e.call(d,c);else for(let a=0;a<b;a++)e.call(d)}function logEntry(a,b){const c=10|(_globals.global.probe&&_globals.global.probe.priority);(0|b.priority)<=c&&a.opts.log(b)}function logResultsAsMarkdownTable({entry:a,id:b,itersPerSecond:c,time:d}){const e=50;switch(a){case LOG_ENTRY.GROUP:console.log(''),console.log(`| ${(0,_formatters.rightPad)(b,e)} | iterations/s |`),console.log(`| ${(0,_formatters.rightPad)('---',e)} | --- |`);break;case LOG_ENTRY.TEST:console.log(`| ${(0,_formatters.rightPad)(b,e)} | ${(0,_formatters.rightPad)(c,12)} |`);break;case LOG_ENTRY.COMPLETE:console.log(''),console.log(`Completed benchmark in ${d}s`);break;default:}}function logResultsAsTree({entry:a,id:b,itersPerSecond:c,time:d}){switch(a){case LOG_ENTRY.GROUP:console.log(''),console.log(`${b}`);break;case LOG_ENTRY.TEST:console.log(`├─ ${b}: ${c} iterations/s`);break;case LOG_ENTRY.COMPLETE:console.log(''),console.log(`Completed benchmark in ${d}s`);break;default:}}function logResultsAsTreeWithElapsed({entry:a,id:b,itersPerSecond:c,time:d}){a===LOG_ENTRY.TEST?console.log(`├─ ${b}: ${c} iterations/s (${d.toFixed(2)}s elapsed)`):logResultsAsTree({entry:a,id:b,itersPerSecond:c,time:d})} | ||
//# sourceMappingURL=bench.js.map |
@@ -1,1 +0,2 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _bench=require('./bench');Object.defineProperty(exports,'Bench',{enumerable:!0,get:function get(){return _interopRequireDefault(_bench).default}}),Object.defineProperty(exports,'LOG_ENTRY',{enumerable:!0,get:function get(){return _bench.LOG_ENTRY}}),Object.defineProperty(exports,'logResultsAsMarkdownTable',{enumerable:!0,get:function get(){return _bench.logResultsAsMarkdownTable}}),Object.defineProperty(exports,'logResultsAsTree',{enumerable:!0,get:function get(){return _bench.logResultsAsTree}}),Object.defineProperty(exports,'logResultsAsTreeWithElapsed',{enumerable:!0,get:function get(){return _bench.logResultsAsTreeWithElapsed}});function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}} | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _bench=require('./bench');Object.defineProperty(exports,'Bench',{enumerable:!0,get:function get(){return _interopRequireDefault(_bench).default}}),Object.defineProperty(exports,'LOG_ENTRY',{enumerable:!0,get:function get(){return _bench.LOG_ENTRY}}),Object.defineProperty(exports,'logResultsAsMarkdownTable',{enumerable:!0,get:function get(){return _bench.logResultsAsMarkdownTable}}),Object.defineProperty(exports,'logResultsAsTree',{enumerable:!0,get:function get(){return _bench.logResultsAsTree}}),Object.defineProperty(exports,'logResultsAsTreeWithElapsed',{enumerable:!0,get:function get(){return _bench.logResultsAsTreeWithElapsed}});function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}} | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,2 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.experimental=exports.Log=exports.VERSION=void 0;var _globals=require('./utils/globals');Object.defineProperty(exports,'VERSION',{enumerable:!0,get:function get(){return _globals.VERSION}});var _log=require('./log/log');Object.defineProperty(exports,'Log',{enumerable:!0,get:function get(){return _interopRequireDefault(_log).default}}),require('./init');var _logToDom=require('./utils/log-to-dom');function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}const experimental=exports.experimental={enableDOMLogging:_logToDom.enableDOMLogging}; | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.experimental=exports.Log=exports.VERSION=void 0;var _globals=require('./lib/utils/globals');Object.defineProperty(exports,'VERSION',{enumerable:!0,get:function get(){return _globals.VERSION}});var _log=require('./lib/log');Object.defineProperty(exports,'Log',{enumerable:!0,get:function get(){return _interopRequireDefault(_log).default}}),require('./init');var _logToDom=require('./lib/utils/log-to-dom');function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}const experimental=exports.experimental={enableDOMLogging:_logToDom.enableDOMLogging}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,2 @@ | ||
'use strict';var _globals=require('./utils/globals');_globals.global.probe={}; | ||
'use strict';var _globals=require('./lib/utils/globals');_globals.global.probe={}; | ||
//# sourceMappingURL=init.js.map |
@@ -1,1 +0,2 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _makeSpy=require('./make-spy');Object.defineProperty(exports,'makeSpy',{enumerable:!0,get:function get(){return _makeSpy.makeSpy}});var _nodeTestDriver=require('./node-test-driver');Object.defineProperty(exports,'NodeTestDriver',{enumerable:!0,get:function get(){return _interopRequireDefault(_nodeTestDriver).default}});function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}} | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});var _makeSpy=require('./make-spy');Object.defineProperty(exports,'makeSpy',{enumerable:!0,get:function get(){return _makeSpy.makeSpy}});var _browserDriver=require('./browser-driver');Object.defineProperty(exports,'BrowserDriver',{enumerable:!0,get:function get(){return _interopRequireDefault(_browserDriver).default}});function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}} | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,2 @@ | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.makeSpy=makeSpy;function makeSpy(a,b){let c;return a||b?'function'!=typeof a||b?(c=b,b=a[c]):(b=a,a={},c=`${b.name}-spy`):(b=function(){},a={},c='spy'),wrapFunction(a,b,c)}function wrapFunction(a,b,c){function d(...a){return d.callCount++,d.called=!0,b.apply(this,a)}return void 0===b.func?(Object.assign(d,{reset(){d.callCount=0,d.called=!1},restore(){a[c]=b},obj:a,methodName:c,func:b,method:b}),d.reset(),a[c]=d,d):b} | ||
'use strict';Object.defineProperty(exports,'__esModule',{value:!0}),exports.makeSpy=makeSpy;function makeSpy(a,b){let c;return a||b?'function'!=typeof a||b?(c=b,b=a[c]):(b=a,a={},c=`${b.name}-spy`):(b=function(){},a={},c='spy'),wrapFunction(a,b,c)}function wrapFunction(a,b,c){function d(...a){return d.callCount++,d.called=!0,b.apply(this,a)}return void 0===b.func?(Object.assign(d,{reset(){d.callCount=0,d.called=!1},restore(){a[c]=b},obj:a,methodName:c,func:b,method:b}),d.reset(),a[c]=d,d):b} | ||
//# sourceMappingURL=make-spy.js.map |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"keywords": [ | ||
@@ -28,5 +28,5 @@ "javascript", | ||
"build-clean": "rm -fr dist dist-es6 && mkdir -p dist dist-es6", | ||
"build-es6": "rm -fr dist-es6 && babel src --out-dir dist-es6", | ||
"build-es5": "rm -fr dist && babel src --out-dir dist --plugins=transform-es2015-modules-commonjs", | ||
"build-size": "(find dist -name '*.js' | xargs wc) && (find dist-es6 -name '*.js' | xargs wc) && (find src -name '*.js' | xargs wc)", | ||
"build-es6": "rm -fr dist-es6 && babel src --out-dir dist-es6 --source-maps", | ||
"build-es5": "rm -fr dist && babel src --out-dir dist --plugins=transform-es2015-modules-commonjs --source-maps", | ||
"build-size": "(echo \"dist size\" ; find dist/lib -name '*.js' | xargs cat | wc -c) && (echo \"dist-es6 size\" ; find dist-es6/lib -name '*.js' | xargs cat | wc -c) && (echo \"source size\" ; find src/lib -name '*.js' | xargs cat | wc -c)", | ||
"build": "npm run build-clean && npm run build-es5 && npm run build-es6 && npm run build-size", | ||
@@ -38,3 +38,3 @@ "cover": "NODE_ENV=test nyc --reporter html --reporter cobertura --reporter=lcov npm run test-cover", | ||
"publish-beta": "npm run test && npm run test-dist && npm publish --tag beta", | ||
"test": "npm run lint && npm run build && npm run test-node", | ||
"test": "npm run lint && npm run test-node && npm run build", | ||
"test-fast": "npm run test-node | faucet", | ||
@@ -41,0 +41,0 @@ "test-cover": "NODE_ENV=test tape -r babel-register test/node.js && nyc report", |
/* eslint-disable no-console */ | ||
/* global setTimeout, console */ | ||
import {formatSI, rightPad} from '../utils/formatters'; | ||
import {global} from '../utils/globals'; | ||
import {autobind} from '../utils/autobind'; | ||
import LocalStorage from '../utils/local-storage'; | ||
import {formatSI, rightPad} from '../lib/utils/formatters'; | ||
import {global} from '../lib/utils/globals'; | ||
import {autobind} from '../lib/utils/autobind'; | ||
import LocalStorage from '../lib/utils/local-storage'; | ||
import assert from 'assert'; | ||
@@ -8,0 +8,0 @@ |
import './init'; | ||
export {VERSION} from './utils/globals'; | ||
export {VERSION} from './lib/utils/globals'; | ||
export {default as Log} from './log/log'; | ||
export {default as Log} from './lib/log'; | ||
// Experimental exports | ||
import {enableDOMLogging} from './utils/log-to-dom'; | ||
import {enableDOMLogging} from './lib/utils/log-to-dom'; | ||
export const experimental = { | ||
@@ -17,3 +17,3 @@ enableDOMLogging | ||
// import Probe from './probe'; | ||
// import {global} from './utils/globals'; | ||
// import {global} from './lib/utils/globals'; | ||
// global.Probe = Probe; |
@@ -1,2 +0,2 @@ | ||
import {global} from './utils/globals'; | ||
import {global} from './lib/utils/globals'; | ||
global.probe = {}; |
@@ -1,7 +0,2 @@ | ||
export { | ||
makeSpy | ||
} from './make-spy'; | ||
export { | ||
default as NodeTestDriver | ||
} from './node-test-driver'; | ||
export {makeSpy} from './make-spy'; | ||
export {default as BrowserDriver} from './browser-driver'; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 4 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 3 instances in 1 package
206869
86
1307
12
1