Should be trivial given the functionality that Ralf has added. Instead of pushing arguments to the stack, push an anonymous object containing startTime, function name, and whatever else you deem necessary. On the pop operation, calculate the time, and push it to some dictionary of function calls. Formatting the output should be a cinch.
Scott
-----Original Message-----
From: [EMAIL PROTECTED] on behalf of David Rorex
Sent: Wed 1/18/2006 7:51 PM
To: Open Source Flash Mailing List
Cc:
Subject: Re: [osflash] hamtasc: stacktrace available
very nice...now we just need someone to write a tool that will record the
entry & exit every time a function is called, as well as a timestamp (from
getTimer()), then process all this data to profile your app, giving output
similar to the gprof tool.
% cumulative self self total
time seconds seconds calls ms/call ms/call name
17.7 3.72 3.72 13786208 0.00 0.00 Ns_DStringNAppend [8]
6.1 5.00 1.28 107276 0.01 0.03 MakePath [10]
2.9 5.60 0.60 1555972 0.00 0.00 Ns_DStringFree [35]
2.7 6.18 0.58 1555965 0.00 0.00 Ns_DStringInit [36]
2.3 6.67 0.49 1507858 0.00 0.00 ns_realloc [40]
[example pulled from random webpage]
That would be helpful for finding bottlenecks in your code.
-David R
On 1/18/06, Ralf Bokelberg <[EMAIL PROTECTED]> wrote:
> I slightly changed the rb_auto_trace option to include the current scope
> and the arguments. Also i added another option rb_auto_trace_pop, which
> is called, whenever a function is left. This way we are able to produce
> stacktraces now, using the following actionscript class
>
> /**
> * @author ralf bokelberg
> */
> class de.bokelberg.debug.AutoTraceStackManager {
> public static var stack:Array = new Array();
>
> public static function push(
> className:String,
> methodName:String,
> fileName:String,
> lineNumber:Number,
> scope:Object,
> arguments:FunctionArguments):Void
> {
> stack.push(arguments);
> }
>
> public static function pop(
> className:String,
> methodName:String,
> fileName:String,
> lineNumber:Number):Void
> {
> stack.pop();
> }
>
> public static function toString():String{
> return stack.join("\n");
> }
> }
>
> You also need to add the following parameters to your build script
> <arg value="-rb_auto_trace"/>
> <arg value="de.bokelberg.debug.AutoTraceStackManager.push"/>
> <arg value="-rb_auto_trace_pop"/>
> <arg value="de.bokelberg.debug.AutoTraceStackManager.pop"/>
> <arg value="de/bokelberg/debug/AutoTraceStackManager" />
>
> Now you can test it in a try/catch for example:
>
>
> import de.bokelberg.debug.AutoTraceStackManager;
>
> /**
> * @author ralf bokelberg
> */
> class test.MainClass {
>
> public static function main( mc:MovieClip):Void{
> var m:MainClass = new MainClass();
> m.test();
> }
>
> public function test():Object{
> try {
> throw( new Error("hey"));
> return null;
> } catch( e:Error){
> trace(e.toString()
> + "\n"
> + AutoTraceStackManager.toString());
> }
> }
> }
>
> And if you run it, you should see something like this output
> (i partly replaced the path by ... below)
>
> hey
> test.MainClass,main,...ss.as,7,[type Function],_level0,
> test.MainClass,test,...ss.as,14,[object Object],
>
> Cheers,
> Ralf.
>
>
>
>
> _______________________________________________
> osflash mailing list
> [email protected]
> http://osflash.org/mailman/listinfo/osflash_osflash.org
>
<<winmail.dat>>
_______________________________________________ osflash mailing list [email protected] http://osflash.org/mailman/listinfo/osflash_osflash.org
