var Test = new Class({ Aspect:'Test', initialize:function(cycle){ for(var c=0;c<cycle;c++) for(var i=0,max=10000;i<max;i++){ //donothing } } }); Profile.addEvent('trace', function(x){console.log(JSON.encode(x))}); var x = new Test(1);//{"description":"Test","uniqueID":4,"name":"initialize","params":{"0":1},"callno":1,"executionTime":1} var y = new Test(1000);//{"description":"Test","uniqueID":5,"name":"initialize","params":{"0":1000},"callno":2,"executionTime":34}
<script src="https://raw.github.com/keeto/mootools-pattern-mutators/master/Source/Class.PatternMutators.js"></script> <script src="https://raw.github.com/gist/1278659/64ee9462dec56a74e0db9ee3f01db3c62f9dd957/kenta.AOP.js"></script> <script src="https://raw.github.com/gist/1275736/24f145a45252400ce2fd4fe1e6ef66071ba85cfb/kenta.AOP.Profile.js"></script> <p> where <dl> <dt>description</dt><dd>Is the string you've associated to the Aspect property</dd> <dt>name</dt><dd>Is the name of your method</dd> <dt>uniqueID</dt><dd>is an ID unique per instance</dd> <dt>params</dt><dd>Are the parameter passed to your method</dd> <dt>callNo</dt><dd>Is the trace order number</dd> <dt>executionTime</dt><dd>Is the execution time of your method(ms)</dd> </dl>
*{ padding:0;margin:0; font-family:'Trebuchet MS',Verdana; font-variant:small-caps; background-color:whitesmoke; } dt{ color:steelblue; padding-left:1em; font-weight:bold; } dd{ padding-left:2em; }