// run this with console open to see the performance metrics
// the zone is initialized/forked at the bottom of the code
var main = function() {
zone.marker = "main";
var btn = document.getElementById("myBtn"),
data = document.getElementById("myData");
btn.addEventListener("click", function() {
zone.marker = "click";
data.innerHTML = "Initializing...";
setTimeout(function() {
zone.marker = "timeout";
data.innerHTML = "Done.";
}, 2000);
});
};
// profile zone from Zone.js examples (modified for this example)
var profilingZone = (function () {
var time = 0,
// use the high-res timer if available
timer = performance ?
performance.now.bind(performance) :
Date.now.bind(Date);
return {
marker: "?",
onZoneEnter: function () {
this.originalStart = this.originalStart || timer();
this.start = timer();
console.log("Entered task");
},
onZoneLeave: function () {
var diff = timer() - this.start,
totalDiff = timer() - this.originalStart;
console.log("Exited task " + zone.marker + " after " + diff);
time += diff;
console.log("Total active time: " + time);
console.log("Total elapsed time: " + totalDiff);
},
reset: function () {
time = 0;
}
};
}());
// this is from https://github.com/angular/zone.js
function Zone(parentZone, data) {
var zone = (arguments.length) ? Object.create(parentZone) : this;
zone.parent = parentZone;
Object.keys(data || {}).forEach(function(property) {
zone[property] = data[property];
});
return zone;
}
Zone.prototype = {
constructor: Zone,
fork: function (locals) {
return new Zone(this, locals);
},
bind: function (fn) {
var zone = this.fork();
return function zoneBoundFn() {
var result = zone.run(fn, this,...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.