Last change
on this file since 256 was
256,
checked in by hendrikvanantwerpen, 13 years ago
|
Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).
|
File size:
670 bytes
|
Line | |
---|
1 | dojo.provide("dojox.lang.aspect.timer"); |
---|
2 | |
---|
3 | (function(){ |
---|
4 | var aop = dojox.lang.aspect, |
---|
5 | uniqueNumber = 0; |
---|
6 | |
---|
7 | var Timer = function(name){ |
---|
8 | this.name = name || ("DojoAopTimer #" + ++uniqueNumber); |
---|
9 | this.inCall = 0; |
---|
10 | }; |
---|
11 | dojo.extend(Timer, { |
---|
12 | before: function(/*arguments*/){ |
---|
13 | if(!(this.inCall++)){ |
---|
14 | console.time(this.name); |
---|
15 | } |
---|
16 | }, |
---|
17 | after: function(/*excp*/){ |
---|
18 | if(!--this.inCall){ |
---|
19 | console.timeEnd(this.name); |
---|
20 | } |
---|
21 | } |
---|
22 | }); |
---|
23 | |
---|
24 | aop.timer = function(/*String?*/ name){ |
---|
25 | // summary: |
---|
26 | // Returns an object, which can be used to time calls to methods. |
---|
27 | // |
---|
28 | // name: |
---|
29 | // The optional unique name of the timer. |
---|
30 | |
---|
31 | return new Timer(name); // Object |
---|
32 | }; |
---|
33 | })(); |
---|
Note: See
TracBrowser
for help on using the repository browser.