Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function test(){ print( "whoa" ); }
- global totaltime = {};
- function inject( src, name )
- {
- totaltime[ name ] = 0;
- counter = function()
- {
- begin = ftime();
- this[0]();
- end = ftime();
- totaltime[ this[1] ] += end - begin;
- };
- return closure( counter, [src,name] );
- }
- test();
- test = inject( test, "test" );
- begin = ftime();
- for( i = 0; i < 1000; ++i )
- test();
- end = ftime();
- printvar( totaltime );
- println( totaltime["test"] $ " out of " $ end-begin $ " seconds spent in 'test'" );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement