marky
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -5,2 +5,3 @@ (function (exports) { | ||
/* global performance */ | ||
var perf = typeof performance !== 'undefined' && performance; | ||
@@ -10,4 +11,4 @@ var now; | ||
{ | ||
if (typeof performance !== 'undefined' && performance.now) { | ||
now = function () { return performance.now(); }; | ||
if (perf && perf.now) { | ||
now = function () { return perf.now(); }; | ||
} else { | ||
@@ -20,4 +21,2 @@ now = function () { return Date.now(); }; | ||
/* global performance */ | ||
function throwIfEmpty (name) { | ||
@@ -45,16 +44,15 @@ if (!name) { | ||
if (typeof performance !== 'undefined' && | ||
performance.mark && performance.measure) { | ||
if (perf && perf.mark && perf.measure) { | ||
exports.mark = function (name) { | ||
throwIfEmpty(name); | ||
performance.mark(("start " + name)); | ||
perf.mark(("start " + name)); | ||
}; | ||
exports.stop = function (name) { | ||
throwIfEmpty(name); | ||
performance.mark(("end " + name)); | ||
performance.measure(name, ("start " + name), ("end " + name)); | ||
var entries = performance.getEntriesByName(name); | ||
perf.mark(("end " + name)); | ||
perf.measure(name, ("start " + name), ("end " + name)); | ||
var entries = perf.getEntriesByName(name); | ||
return entries[entries.length - 1] | ||
}; | ||
exports.getEntries = function () { return performance.getEntriesByType('measure'); }; | ||
exports.getEntries = function () { return perf.getEntriesByType('measure'); }; | ||
} else { | ||
@@ -61,0 +59,0 @@ var marks = {}; |
@@ -1,1 +0,1 @@ | ||
!function(r){"use strict";function e(r){if(!r)throw new Error("name must be non-empty")}function n(r,e){for(var n,t=0,a=r.length;t<a;)n=t+a>>>1,r[n].startTime<e.startTime?t=n+1:a=n;r.splice(t,0,e)}var t;t="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return Date.now()};var a=t;if("undefined"!=typeof performance&&performance.mark&&performance.measure)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]},r.getEntries=function(){return performance.getEntriesByType("measure")};else{var o={},m=[];r.mark=function(r){var n=a();e(r),o["$"+r]=n},r.stop=function(r){var t=a();e(r);var f=o["$"+r];if(!f)throw new Error("no known mark: "+r);var i={startTime:f,name:r,duration:t-f,entryType:"measure"};return n(m,i),i},r.getEntries=function(){return m}}}(this.marky=this.marky||{}); | ||
!function(r){"use strict";function n(r){if(!r)throw new Error("name must be non-empty")}function e(r,n){for(var e,t=0,a=r.length;t<a;)e=t+a>>>1,r[e].startTime<n.startTime?t=e+1:a=e;r.splice(t,0,n)}var t,a="undefined"!=typeof performance&&performance;t=a&&a.now?function(){return a.now()}:function(){return Date.now()};var o=t;if(a&&a.mark&&a.measure)r.mark=function(r){n(r),a.mark("start "+r)},r.stop=function(r){n(r),a.mark("end "+r),a.measure(r,"start "+r,"end "+r);var e=a.getEntriesByName(r);return e[e.length-1]},r.getEntries=function(){return a.getEntriesByType("measure")};else{var i={},u=[];r.mark=function(r){var e=o();n(r),i["$"+r]=e},r.stop=function(r){var t=o();n(r);var a=i["$"+r];if(!a)throw new Error("no known mark: "+r);var m={startTime:a,name:r,duration:t-a,entryType:"measure"};return e(u,m),m},r.getEntries=function(){return u}}}(this.marky=this.marky||{}); |
@@ -6,2 +6,3 @@ 'use strict'; | ||
/* global performance */ | ||
var perf = typeof performance !== 'undefined' && performance; | ||
@@ -11,4 +12,4 @@ var now; | ||
{ | ||
if (typeof performance !== 'undefined' && performance.now) { | ||
now = function () { return performance.now(); }; | ||
if (perf && perf.now) { | ||
now = function () { return perf.now(); }; | ||
} else { | ||
@@ -21,4 +22,2 @@ now = function () { return Date.now(); }; | ||
/* global performance */ | ||
function throwIfEmpty (name) { | ||
@@ -46,16 +45,15 @@ if (!name) { | ||
if (typeof performance !== 'undefined' && | ||
performance.mark && performance.measure) { | ||
if (perf && perf.mark && perf.measure) { | ||
exports.mark = function (name) { | ||
throwIfEmpty(name); | ||
performance.mark(("start " + name)); | ||
perf.mark(("start " + name)); | ||
}; | ||
exports.stop = function (name) { | ||
throwIfEmpty(name); | ||
performance.mark(("end " + name)); | ||
performance.measure(name, ("start " + name), ("end " + name)); | ||
var entries = performance.getEntriesByName(name); | ||
perf.mark(("end " + name)); | ||
perf.measure(name, ("start " + name), ("end " + name)); | ||
var entries = perf.getEntriesByName(name); | ||
return entries[entries.length - 1] | ||
}; | ||
exports.getEntries = function () { return performance.getEntriesByType('measure'); }; | ||
exports.getEntries = function () { return perf.getEntriesByType('measure'); }; | ||
} else { | ||
@@ -62,0 +60,0 @@ var marks = {}; |
/* global performance */ | ||
var perf = typeof performance !== 'undefined' && performance; | ||
@@ -6,4 +7,4 @@ var now; | ||
{ | ||
if (typeof performance !== 'undefined' && performance.now) { | ||
now = function () { return performance.now(); }; | ||
if (perf && perf.now) { | ||
now = function () { return perf.now(); }; | ||
} else { | ||
@@ -16,4 +17,2 @@ now = function () { return Date.now(); }; | ||
/* global performance */ | ||
function throwIfEmpty (name) { | ||
@@ -45,16 +44,15 @@ if (!name) { | ||
if (typeof performance !== 'undefined' && | ||
performance.mark && performance.measure) { | ||
if (perf && perf.mark && perf.measure) { | ||
mark = function (name) { | ||
throwIfEmpty(name); | ||
performance.mark(("start " + name)); | ||
perf.mark(("start " + name)); | ||
}; | ||
stop = function (name) { | ||
throwIfEmpty(name); | ||
performance.mark(("end " + name)); | ||
performance.measure(name, ("start " + name), ("end " + name)); | ||
var entries = performance.getEntriesByName(name); | ||
perf.mark(("end " + name)); | ||
perf.measure(name, ("start " + name), ("end " + name)); | ||
var entries = perf.getEntriesByName(name); | ||
return entries[entries.length - 1] | ||
}; | ||
getEntries = function () { return performance.getEntriesByType('measure'); }; | ||
getEntries = function () { return perf.getEntriesByType('measure'); }; | ||
} else { | ||
@@ -61,0 +59,0 @@ var marks = {}; |
@@ -6,2 +6,3 @@ 'use strict'; | ||
/* global performance */ | ||
var perf = typeof performance !== 'undefined' && performance; | ||
@@ -24,4 +25,2 @@ var now; | ||
/* global performance */ | ||
function throwIfEmpty (name) { | ||
@@ -49,16 +48,15 @@ if (!name) { | ||
if (typeof performance !== 'undefined' && | ||
performance.mark && performance.measure) { | ||
if (perf && perf.mark && perf.measure) { | ||
exports.mark = function (name) { | ||
throwIfEmpty(name); | ||
performance.mark(("start " + name)); | ||
perf.mark(("start " + name)); | ||
}; | ||
exports.stop = function (name) { | ||
throwIfEmpty(name); | ||
performance.mark(("end " + name)); | ||
performance.measure(name, ("start " + name), ("end " + name)); | ||
var entries = performance.getEntriesByName(name); | ||
perf.mark(("end " + name)); | ||
perf.measure(name, ("start " + name), ("end " + name)); | ||
var entries = perf.getEntriesByName(name); | ||
return entries[entries.length - 1] | ||
}; | ||
exports.getEntries = function () { return performance.getEntriesByType('measure'); }; | ||
exports.getEntries = function () { return perf.getEntriesByType('measure'); }; | ||
} else { | ||
@@ -65,0 +63,0 @@ var marks = {}; |
/* global performance */ | ||
var perf = typeof performance !== 'undefined' && performance; | ||
@@ -19,4 +20,2 @@ var now; | ||
/* global performance */ | ||
function throwIfEmpty (name) { | ||
@@ -48,16 +47,15 @@ if (!name) { | ||
if (typeof performance !== 'undefined' && | ||
performance.mark && performance.measure) { | ||
if (perf && perf.mark && perf.measure) { | ||
mark = function (name) { | ||
throwIfEmpty(name); | ||
performance.mark(("start " + name)); | ||
perf.mark(("start " + name)); | ||
}; | ||
stop = function (name) { | ||
throwIfEmpty(name); | ||
performance.mark(("end " + name)); | ||
performance.measure(name, ("start " + name), ("end " + name)); | ||
var entries = performance.getEntriesByName(name); | ||
perf.mark(("end " + name)); | ||
perf.measure(name, ("start " + name), ("end " + name)); | ||
var entries = perf.getEntriesByName(name); | ||
return entries[entries.length - 1] | ||
}; | ||
getEntries = function () { return performance.getEntriesByType('measure'); }; | ||
getEntries = function () { return perf.getEntriesByType('measure'); }; | ||
} else { | ||
@@ -64,0 +62,0 @@ var marks = {}; |
{ | ||
"name": "marky", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Performance timer based on performance.mark() and measure()", | ||
@@ -5,0 +5,0 @@ "main": "lib/marky.cjs.js", |
@@ -47,3 +47,3 @@ marky [![Build Status](https://travis-ci.org/nolanlawson/marky.svg?branch=master)](https://travis-ci.org/nolanlawson/marky) | ||
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. | ||
[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). Tools like [WebPageTest](http://blog.patrickmeenan.com/2013/07/measuring-performance-of-user-experience.html) and [Windows Performance Analyzer](https://blogs.windows.com/msedgedev/2016/05/11/top-down-analysis-wpt/) also surface them, and you can even [send them to your analytics provider](https://codelabs.developers.google.com/codelabs/performance-analytics/index.html). | ||
@@ -156,2 +156,7 @@ API | ||
See also | ||
--- | ||
- [appmetrics.js](https://github.com/ebidel/appmetrics.js) – a library on top of `mark()`/`measure()` which reports to Google Analytics. | ||
Credits | ||
@@ -158,0 +163,0 @@ ---- |
164
29399
392