Socket
Socket
Sign inDemoInstall

marky

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.1.0

28

dist/marky.js

@@ -22,2 +22,18 @@ (function (exports) {

// simple binary sort insertion
function insertSorted (arr, item, comparator) {
var low = 0;
var high = arr.length;
var mid;
while (low < high) {
mid = (low + high) >>> 1;
if (comparator(arr[mid]) < comparator(item)) {
low = mid + 1;
} else {
high = mid;
}
}
arr.splice(low, 0, item);
}
/* global performance */

@@ -43,4 +59,6 @@

};
exports.getEntries = function () { return performance.getEntriesByType('measure'); };
} else {
var marks = {};
var entries = [];
exports.mark = function (name) {

@@ -58,3 +76,3 @@ var startTime = now$1();

}
return {
var entry = {
startTime: startTime,

@@ -64,6 +82,12 @@ name: name,

entryType: 'measure'
}
};
// per the spec this should be at least 150:
// https://www.w3.org/TR/resource-timing-1/#extensions-performance-interface
// we just have no limit, per Chrome and Edge's de-facto behavior
insertSorted(entries, entry, function (x) { return x.startTime; });
return entry
};
exports.getEntries = function () { return entries; };
}
}((this.marky = this.marky || {})));

2

dist/marky.min.js

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

!function(r){"use strict";function e(r){if(!r)throw new Error("name must be non-empty")}var n;n="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return Date.now()};var a=n,t="undefined"!=typeof performance&&performance.mark&&performance.measure;if(t)r.mark=function(r){e(r),performance.mark("start "+r)},r.stop=function(r){e(r),performance.mark("end "+r),performance.measure(r,"start "+r,"end "+r);var n=performance.getEntriesByName(r);return n[n.length-1]};else{var o={};r.mark=function(r){var n=a();e(r),o["$"+r]=n},r.stop=function(r){var n=a();e(r);var t=o["$"+r];if(!t)throw new Error("no known mark: "+r);return{startTime:t,name:r,duration:n-t,entryType:"measure"}}}}(this.marky=this.marky||{});
!function(r){"use strict";function e(r,e,n){for(var t,a=0,o=r.length;a<o;)t=a+o>>>1,n(r[t])<n(e)?a=t+1:o=t;r.splice(a,0,e)}function n(r){if(!r)throw new Error("name must be non-empty")}var t;t="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return Date.now()};var a=t,o="undefined"!=typeof performance&&performance.mark&&performance.measure;if(o)r.mark=function(r){n(r),performance.mark("start "+r)},r.stop=function(r){n(r),performance.mark("end "+r),performance.measure(r,"start "+r,"end "+r);var e=performance.getEntriesByName(r);return e[e.length-1]},r.getEntries=function(){return performance.getEntriesByType("measure")};else{var f={},m=[];r.mark=function(r){var e=a();n(r),f["$"+r]=e},r.stop=function(r){var t=a();n(r);var o=f["$"+r];if(!o)throw new Error("no known mark: "+r);var i={startTime:o,name:r,duration:t-o,entryType:"measure"};return e(m,i,function(r){return r.startTime}),i},r.getEntries=function(){return m}}}(this.marky=this.marky||{});

@@ -23,2 +23,18 @@ 'use strict';

// simple binary sort insertion
function insertSorted (arr, item, comparator) {
var low = 0;
var high = arr.length;
var mid;
while (low < high) {
mid = (low + high) >>> 1;
if (comparator(arr[mid]) < comparator(item)) {
low = mid + 1;
} else {
high = mid;
}
}
arr.splice(low, 0, item);
}
/* global performance */

@@ -44,4 +60,6 @@

};
exports.getEntries = function () { return performance.getEntriesByType('measure'); };
} else {
var marks = {};
var entries = [];
exports.mark = function (name) {

@@ -59,3 +77,3 @@ var startTime = now$1();

}
return {
var entry = {
startTime: startTime,

@@ -65,4 +83,10 @@ name: name,

entryType: 'measure'
}
};
// per the spec this should be at least 150:
// https://www.w3.org/TR/resource-timing-1/#extensions-performance-interface
// we just have no limit, per Chrome and Edge's de-facto behavior
insertSorted(entries, entry, function (x) { return x.startTime; });
return entry
};
exports.getEntries = function () { return entries; };
}

@@ -19,2 +19,18 @@ /* global performance */

// simple binary sort insertion
function insertSorted (arr, item, comparator) {
var low = 0;
var high = arr.length;
var mid;
while (low < high) {
mid = (low + high) >>> 1;
if (comparator(arr[mid]) < comparator(item)) {
low = mid + 1;
} else {
high = mid;
}
}
arr.splice(low, 0, item);
}
/* global performance */

@@ -30,2 +46,3 @@

var stop;
var getEntries;

@@ -44,4 +61,6 @@ if (supportsMarkMeasure) {

};
getEntries = function () { return performance.getEntriesByType('measure'); };
} else {
var marks = {};
var entries = [];
mark = function (name) {

@@ -59,3 +78,3 @@ var startTime = now$1();

}
return {
var entry = {
startTime: startTime,

@@ -65,6 +84,12 @@ name: name,

entryType: 'measure'
}
};
// per the spec this should be at least 150:
// https://www.w3.org/TR/resource-timing-1/#extensions-performance-interface
// we just have no limit, per Chrome and Edge's de-facto behavior
insertSorted(entries, entry, function (x) { return x.startTime; });
return entry
};
getEntries = function () { return entries; };
}
export { mark, stop };
export { mark, stop, getEntries };

@@ -27,2 +27,18 @@ 'use strict';

// simple binary sort insertion
function insertSorted (arr, item, comparator) {
var low = 0;
var high = arr.length;
var mid;
while (low < high) {
mid = (low + high) >>> 1;
if (comparator(arr[mid]) < comparator(item)) {
low = mid + 1;
} else {
high = mid;
}
}
arr.splice(low, 0, item);
}
/* global performance */

@@ -48,4 +64,6 @@

};
exports.getEntries = function () { return performance.getEntriesByType('measure'); };
} else {
var marks = {};
var entries = [];
exports.mark = function (name) {

@@ -63,3 +81,3 @@ var startTime = now$1();

}
return {
var entry = {
startTime: startTime,

@@ -69,4 +87,10 @@ name: name,

entryType: 'measure'
}
};
// per the spec this should be at least 150:
// https://www.w3.org/TR/resource-timing-1/#extensions-performance-interface
// we just have no limit, per Chrome and Edge's de-facto behavior
insertSorted(entries, entry, function (x) { return x.startTime; });
return entry
};
exports.getEntries = function () { return entries; };
}

@@ -23,2 +23,18 @@ /* global performance */

// simple binary sort insertion
function insertSorted (arr, item, comparator) {
var low = 0;
var high = arr.length;
var mid;
while (low < high) {
mid = (low + high) >>> 1;
if (comparator(arr[mid]) < comparator(item)) {
low = mid + 1;
} else {
high = mid;
}
}
arr.splice(low, 0, item);
}
/* global performance */

@@ -34,2 +50,3 @@

var stop;
var getEntries;

@@ -48,4 +65,6 @@ if (supportsMarkMeasure) {

};
getEntries = function () { return performance.getEntriesByType('measure'); };
} else {
var marks = {};
var entries = [];
mark = function (name) {

@@ -63,3 +82,3 @@ var startTime = now$1();

}
return {
var entry = {
startTime: startTime,

@@ -69,6 +88,12 @@ name: name,

entryType: 'measure'
}
};
// per the spec this should be at least 150:
// https://www.w3.org/TR/resource-timing-1/#extensions-performance-interface
// we just have no limit, per Chrome and Edge's de-facto behavior
insertSorted(entries, entry, function (x) { return x.startTime; });
return entry
};
getEntries = function () { return entries; };
}
export { mark, stop };
export { mark, stop, getEntries };
{
"name": "marky",
"version": "1.0.0",
"version": "1.1.0",
"description": "Performance timer based on performance.mark() and measure()",

@@ -5,0 +5,0 @@ "main": "lib/marky.cjs.js",

@@ -36,3 +36,3 @@ marky [![Build Status](https://travis-ci.org/nolanlawson/marky.svg?branch=master)](https://travis-ci.org/nolanlawson/marky)

`mark()` and `measure()` are [more performant](https://twitter.com/Runspired/status/811007272671293440)
The [User Timing API](https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API) is [more performant](https://twitter.com/Runspired/status/811007272671293440)
than `console.time()` and `console.timeEnd()`,

@@ -47,11 +47,5 @@ and [more accurate](https://developer.mozilla.org/en-US/docs/Web/API/Performance/now) than `Date.now()`. Also, you get nice visualizations in Chrome Dev Tools:

Plus, it records
[PerformanceEntries](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry) that you can access through
the standard [Performance API](https://developer.mozilla.org/en-US/docs/Web/API/Performance):
This is because `marky` adds standard
[PerformanceEntries](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry) to the [Performance Timeline](https://developer.mozilla.org/en-US/docs/Web/API/Performance_Timeline). In principle other browsers and analytics providers can use the same data.
```js
// get all startTimes, names, and durations
var measurements = performance.getEntriesByType('measure');
```
API

@@ -102,6 +96,37 @@ ---

You can get all entries using:
```js
var entries = marky.getEntries();
```
This provides a list of all measures ordered by `startTime`, e.g.:
```json
[
{
"entryType": "measure",
"startTime": 1974112,
"duration": 350,
"name": "numberOne"
},
{
"entryType": "measure",
"startTime": 1975108,
"duration": 300,
"name": "numberTwo"
},
{
"entryType": "measure",
"startTime": 1976127,
"duration": 250,
"name": "numberThree"
}
]
```
Browser support
----
Marky is tested in the following browsers/environments:
`marky` is tested in the following browsers/environments:

@@ -116,1 +141,22 @@ * IE 9+

* Node 4+
Per [the spec](https://www.w3.org/TR/resource-timing-1/#extensions-performance-interface), browsers only need to hold a minimum
of 150 entries in their Performance Timeline buffer. Notably Firefox throttles their buffer to 150, which for `marky`
means you can get a maximum of 50 entries from `marky.getEntries()` (because `marky` creates two marks and a measure).
If you need to get more than 50 entries from `marky.getEntries()`, you can do:
```js
if (typeof performance !== 'undefined' && performance.setResourceTimingBufferSize) {
performance.setResourceTimingBufferSize(10000); // or however many you need
}
```
In Node and [browsers that don't support the User Timing API](http://caniuse.com/#feat=user-timing),
`marky` follows the behavior of Edge and Chrome, and does not limit the number of entries. `marky.stop()` and
`marky.getEntries()` will return pseudo-`PerformanceEntry` objects.
Credits
----
Thanks to [@toddreifsteck](https://github.com/toddreifsteck) for feedback on this project and clarifications on the User Timing API.
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc