[Tinyos-help] Calculate time taken for a function execution.

Roadstar Runner redstripeva2 at gmail.com
Sat Dec 7 08:09:46 PST 2013


I think you have the wrong format specifier argument. Try %ld instead of %f.
Try using
dbg("Boot", "Function took %ld millisecs\n", (ts1 - ts) );




On Sat, Dec 7, 2013 at 6:53 AM, nivedita datta <sweetnivi88 at gmail.com>wrote:

> I am trying to calculate the time taken by a function that I wrote. I am
> using the component LocalTimeMilliC to do this. I have added the
> following lines to the configuration file:
>
> *components LocalTimeMilliC;
> TestC.LocalTime -> LocalTimeMilliC;*
>
> ...and in the module section of the implementation:
>
> *uses interface LocalTime<TMilli>;*
>
> ...and in the code:
>
> *uint32_t timestamp, timestamp1;**timestamp = call LocalTime.get();
> **...
> function called here ...
> ...
> timestamp1 = call LocalTime.get();
> dbg("Boot", "Function took %f millisecs\n", (ts1 - ts) );
> *
>
> However, it always prints the value as 0.000000 millisecs. Please let me know what am I doing wrong in this code or if there is a
> better method to  calculate the time taken for execution of a function.
> Thanks for your time & effort.
> Regards, Nivedita Datta
>
>
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help at millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://www.millennium.berkeley.edu/pipermail/tinyos-help/attachments/20131207/120b6534/attachment-0001.htm 


More information about the Tinyos-help mailing list