Skip to content

Commit 6f824c1

Browse files
committed
added profile method call snippet
1 parent 6483bb0 commit 6f824c1

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

profile-method-call.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(function profileMethodCall() {
2+
var object = primesApp;
3+
var methodName = 'findFirstPrimes';
4+
var originalMethod = object[methodName];
5+
console.assert(typeof originalMethod === 'function', 'cannot find method ' + methodName);
6+
object[methodName] = function () {
7+
console.profile(methodName);
8+
originalMethod.call(object);
9+
console.profileEnd(methodName);
10+
// restore original methodName
11+
object[methodName] = originalMethod;
12+
};
13+
}());

time-method-call.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(function profileMethodCall() {
1+
(function timeMethodCall() {
22
var object = primesApp;
33
var methodName = 'findFirstPrimes';
44
var originalMethod = object[methodName];

0 commit comments

Comments
 (0)