Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

function-benchmark-util

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

function-benchmark-util - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

2

dist/index.bundle.js

@@ -1,1 +0,1 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).FunctionBenchmarkUtil={})}(this,(function(e){"use strict";function n(e,n,i,t){let r,u=0,c=0,s=Number.MAX_SAFE_INTEGER;for(let a=1;a<=n;a++){const l=o(),m=e.apply(i,t),d=o()-l;u+=d,d<s&&(s=d),d>c&&(c=d),a===n&&(r=m)}return{functionName:e.name,fnReturns:r,runCount:n,min:s,max:c,average:u/n}}function o(){var e,n,o,i,t;let r;if(null===(n=null===(e=global)||void 0===e?void 0:e.process)||void 0===n?void 0:n.hrtime){const e=process.hrtime();r=(1e9*e[0]+e[1])/1e3}else(null===(i=null===(o=window)||void 0===o?void 0:o.performance)||void 0===i?void 0:i.now)?r=1e3*performance.now():(null===(t=console)||void 0===t||t.error("Benchmark time precision is in millisecons due to the unrecognized environment!"),r=1e3*Date.now());return r}function i(e,n){return Math.round(e/1e3*Math.pow(10,n))/Math.pow(10,n)}e.benchmark=function(e,o){return n(e,1,null,o)},e.benchmarkTimes=function(e,o,i){return n(e,o,void 0,i)},e.benchmarkTimesWithThis=n,e.benchmarkWithThis=function(e,o,i){return n(e,1,o,i)},e.convertTimeToMilliseconds=function(e,n=2){return Object.assign({},e,{min:i(e.min,n),max:i(e.max,n),average:i(e.average,n)})},e.tsInMicroseconds=o,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).FunctionBenchmarkUtil={})}(this,(function(e){"use strict";function n(e,n,i,t){let r,c=0,u=0,l=Number.MAX_SAFE_INTEGER;for(let s=1;s<=n;s++){const a=o(),d=e.apply(i,t),m=o()-a;c+=m,m<l&&(l=m),m>u&&(u=m),s===n&&(r=d)}return{functionName:e.name,fnReturns:r,runCount:n,min:l,max:u,average:c/n}}function o(){var e,n;let o;if(null===(e=null===global||void 0===global?void 0:global.process)||void 0===e?void 0:e.hrtime){const e=process.hrtime();o=(1e9*e[0]+e[1])/1e3}else(null===(n=null===window||void 0===window?void 0:window.performance)||void 0===n?void 0:n.now)?o=1e3*performance.now():(null===console||void 0===console||console.error("Benchmark time precision is in millisecons due to the unrecognized environment!"),o=1e3*Date.now());return o}function i(e,n){return Math.round(e/1e3*Math.pow(10,n))/Math.pow(10,n)}e.benchmark=function(e,o){return n(e,1,null,o)},e.benchmarkTimes=function(e,o,i){return n(e,o,void 0,i)},e.benchmarkTimesWithThis=n,e.benchmarkWithThis=function(e,o,i){return n(e,1,o,i)},e.convertTimeToMilliseconds=function(e,n=2){return Object.assign({},e,{min:i(e.min,n),max:i(e.max,n),average:i(e.average,n)})},e.tsInMicroseconds=o,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -1,1 +0,1 @@

function n(n,e){return r(n,1,null,e)}function e(n,e,o){return r(n,1,e,o)}function o(n,e,o){return r(n,e,void 0,o)}function r(n,e,o,r){let t,u=0,a=0,l=Number.MAX_SAFE_INTEGER;for(let c=1;c<=e;c++){const m=i(),s=n.apply(o,r),v=i()-m;u+=v,v<l&&(l=v),v>a&&(a=v),c===e&&(t=s)}return{functionName:n.name,fnReturns:t,runCount:e,min:l,max:a,average:u/e}}function i(){var n,e,o,r,i;let t;if(null===(e=null===(n=global)||void 0===n?void 0:n.process)||void 0===e?void 0:e.hrtime){const n=process.hrtime();t=(1e9*n[0]+n[1])/1e3}else(null===(r=null===(o=window)||void 0===o?void 0:o.performance)||void 0===r?void 0:r.now)?t=1e3*performance.now():(null===(i=console)||void 0===i||i.error("Benchmark time precision is in millisecons due to the unrecognized environment!"),t=1e3*Date.now());return t}function t(n,e){return Math.round(n/1e3*Math.pow(10,e))/Math.pow(10,e)}function u(n,e=2){return Object.assign({},n,{min:t(n.min,e),max:t(n.max,e),average:t(n.average,e)})}export{n as benchmark,o as benchmarkTimes,r as benchmarkTimesWithThis,e as benchmarkWithThis,u as convertTimeToMilliseconds,i as tsInMicroseconds};
function n(n,e){return r(n,1,null,e)}function e(n,e,o){return r(n,1,e,o)}function o(n,e,o){return r(n,e,void 0,o)}function r(n,e,o,r){let t,l=0,u=0,a=Number.MAX_SAFE_INTEGER;for(let c=1;c<=e;c++){const m=i(),s=n.apply(o,r),d=i()-m;l+=d,d<a&&(a=d),d>u&&(u=d),c===e&&(t=s)}return{functionName:n.name,fnReturns:t,runCount:e,min:a,max:u,average:l/e}}function i(){var n,e;let o;if(null===(n=null===global||void 0===global?void 0:global.process)||void 0===n?void 0:n.hrtime){const n=process.hrtime();o=(1e9*n[0]+n[1])/1e3}else(null===(e=null===window||void 0===window?void 0:window.performance)||void 0===e?void 0:e.now)?o=1e3*performance.now():(null===console||void 0===console||console.error("Benchmark time precision is in millisecons due to the unrecognized environment!"),o=1e3*Date.now());return o}function t(n,e){return Math.round(n/1e3*Math.pow(10,e))/Math.pow(10,e)}function l(n,e=2){return Object.assign({},n,{min:t(n.min,e),max:t(n.max,e),average:t(n.average,e)})}export{n as benchmark,o as benchmarkTimes,r as benchmarkTimesWithThis,e as benchmarkWithThis,l as convertTimeToMilliseconds,i as tsInMicroseconds};

@@ -69,9 +69,9 @@ /**

export function tsInMicroseconds() {
var _a, _b, _c, _d, _e;
var _a, _b;
let now;
if ((_b = (_a = global) === null || _a === void 0 ? void 0 : _a.process) === null || _b === void 0 ? void 0 : _b.hrtime) {
if ((_a = global === null || global === void 0 ? void 0 : global.process) === null || _a === void 0 ? void 0 : _a.hrtime) {
const hrt = process.hrtime();
now = (1e9 * hrt[0] + hrt[1]) / 1e3;
}
else if ((_d = (_c = window) === null || _c === void 0 ? void 0 : _c.performance) === null || _d === void 0 ? void 0 : _d.now) {
else if ((_b = window === null || window === void 0 ? void 0 : window.performance) === null || _b === void 0 ? void 0 : _b.now) {
now = 1e3 * performance.now();

@@ -81,3 +81,3 @@ }

// tslint:disable-next-line: no-console
(_e = console) === null || _e === void 0 ? void 0 : _e.error('Benchmark time precision is in millisecons due to the unrecognized environment!');
console === null || console === void 0 ? void 0 : console.error('Benchmark time precision is in millisecons due to the unrecognized environment!');
now = 1e3 * Date.now();

@@ -84,0 +84,0 @@ }

{
"name": "function-benchmark-util",
"version": "0.0.4",
"version": "0.0.5",
"description": "A library to benchmark javascript functions.",

@@ -37,3 +37,3 @@ "main": "dist/index.js",

"ts-node": "^8.6.2",
"tslint": "^6.0.0",
"tslint": "^6.1.1",
"tslint-config-prettier": "^1.18.0",

@@ -40,0 +40,0 @@ "typedoc": "^0.16.10",

@@ -31,3 +31,3 @@ # JavaScript Function Benchmark Utility

| Field | Description |
| Property | `type` & Description |
|------:|:------------|

@@ -52,2 +52,4 @@ | functionName |`string` Name of the executed function |

![David](https://img.shields.io/david/cengizcan/function-benchmark-util?style=flat-square) ![David](https://img.shields.io/david/dev/cengizcan/function-benchmark-util?style=flat-square) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/function-benchmark-util?style=flat-square)
![David](https://img.shields.io/david/cengizcan/function-benchmark-util?style=flat-square) ![David](https://img.shields.io/david/dev/cengizcan/function-benchmark-util?style=flat-square) ![npm bundle size](https://img.shields.io/bundlephobia/minzip/function-benchmark-util?style=flat-square)
TODO: improve docs and examples.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc