3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-26 20:55:52 +02:00

Update usertimingExample.js

This commit is contained in:
James B. Pollack 2015-11-06 21:39:53 -08:00
parent f478261ed0
commit 4fbff5d667

View file

@ -1,16 +1,16 @@
Script.include('usertiming.js');
var timing = loadUserTiming();
//set a mark
timing.performance.mark('mark_fully_loaded')
timing.performance.mark('firstMark')
//do something that takes time -- we're just going to set a timeout here as an example
var count = 0;
Script.setTimeout(function() {
//do something that takes time
//and set another mark
timing.performance.mark('mark_fully_loaded2')
timing.performance.mark('secondMark')
//measure time between marks (first parameter is a name for the measurement)
timing.performance.measure('howlong', 'mark_fully_loaded', 'mark_fully_loaded2');
//you can also get the marks, but the measure is usually what you're looking for
var items = timing.performance.getEntriesByType('measure');
print('items is:::' + JSON.stringify(items))
}, 1000)
timing.performance.measure('howlong', 'firstMark', 'secondMark');
//you can also get the marks by changing the type below
var measures = timing.performance.getEntriesByType('measure');
print('measures:::' + JSON.stringify(measures))
}, 1000)