Skip to content

Commit

Permalink
rename vars and remove marginal commentary
Browse files Browse the repository at this point in the history
  • Loading branch information
mykmelez committed Sep 22, 2014
1 parent 820decf commit 32746dd
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,26 @@ var Instrument = {

var now = Date.now();

// Since we're (temporarily) exiting the caller, calculate how much time
// we've spent in it so far.
if (caller.profileData) {
caller.profileData.callTime += now - caller.profileData.lastTime;
caller.profileData.cost += now - caller.profileData.then;
}

// Now initialize the profile data structure for the callee we're entering.
callee.profileData = {
callTime: 0,
lastTime: now,
cost: 0,
then: now,
};
},

callExitHooks: function(methodInfo, caller, callee) {
var key = this.getKey(methodInfo);
var now = Date.now();

// Now that we're exiting the callee, calculate the last amount of time
// we spent in it and then record the total time.
callee.profileData.callTime += now - callee.profileData.lastTime;
callee.profileData.cost += now - callee.profileData.then;
var times = this.profile[key] || (this.profile[key] = []);
times.push(callee.profileData.callTime);
times.push(callee.profileData.cost);

// Now that we're re-entering the caller, start tracking the amount of time
// we spend in it again.
if (caller.profileData) {
caller.profileData.lastTime = now;
caller.profileData.then = now;
}

if (Instrument.exit[key]) {
Expand All @@ -57,13 +50,13 @@ var Instrument = {

callPauseHooks: function(frame) {
if (frame.profileData) {
frame.profileData.callTime += Date.now() - frame.profileData.lastTime;
frame.profileData.cost += Date.now() - frame.profileData.then;
}
},

callResumeHooks: function(frame) {
if (frame.profileData) {
frame.profileData.lastTime = Date.now();
frame.profileData.then = Date.now();
}
},

Expand Down

0 comments on commit 32746dd

Please sign in to comment.