Message Boards Message Boards

0
|
1996 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Timing a calculation within a loop

Posted 9 years ago

I am attempting a somewhat long calculation and would like to get timing statistics on each calculation that is performed within a loop. My current implementation, which is not working, looks like this:

T = AbsoluteTime[];
t  = AbsoluteTime[];

fname = "...\\output.tsv";
Put[ fname ];
For[ i = 1, i < maximum, i++,
    (* Calculations that are very time consuming matrix operations *)

t = AbsoluteTime[] - t;
Print[t];
PutAppend[ t , fname];
];
T = AbsoluteTime[] - T;
Print[T];

The output in Mathematica looks like (first t values, then T): "0.019978 0.020020 ....

309.0389375"

The output to the file looks like: 0.0199729.94155819549696 0.0200207.38343434343434

There are two problems: First, the t values are not accurate. They are at least an order of magnitude smaller than expected. Second, the outputs to the .tsv file don't match the values output within the Mathematica notebook; the sum of the t's isn't equal to T.

Thanks!

POSTED BY: Jon Spalding
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract