Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Display Calculation Time, How?

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-21-2014
07:34 PM

04-21-2014
07:34 PM

Hello,

I am supposed to get cpu execution times for several different matrix manipulations, but I am unsure how to do it. For instance, I need to invert a 10x10 matrix, and then invert a 100x100 matrix, and show the cpu calc times for each. Is there somebody that knows how to do this? i've attached my worksheet.

Thanks!!!

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-21-2014
10:26 PM

04-21-2014
10:26 PM

If we construct a function (calculation time to solve system vs. number of unknown) we see, if we plot in in a log-log scale that it looks approx. like a straight line. Timing in Mathcad isn't that accurate and we don't know how to compensate for time to function call and looping.

So it seems to be a good idea to try a powerfit

which show that the time is approx proportional to x^3.15 which may be x^3 for more precise timing!?

Also extrapolations using the powerfunction are quite good

Unfortuately Mathcad won't be able to deal with much larger matrices than 4000x4000 but the tendency is well seen anyway.

8 REPLIES 8

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-21-2014
08:10 PM

04-21-2014
08:10 PM

Re: Display Calculation Time, How?

As long as you ar enot using Prime there is a way to do it.

time(0) (any integer agrument will do) returns a time in second with a precision of ms. Call it before execution of th efunction you wish to time and then after and view the difference. Best done if all is put in a program so you can be sure the time() command will really be evaluated.

For calculations which take not much time to exectute you may use a loop to execute them repeatedly a couple of times.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-22-2014
02:22 PM

04-22-2014
02:22 PM

Re: Display Calculation Time, How?

Werner…

Prime 3.0 (at least) has the ** time()** function, so I was able to duplicate your program. However, rather than play around with matrix inversions, I substituted other operations for

BTW, I'm using a 2.5 GHz quad-core Dell Latitude E5520 (Core i5 processor)

All this proves your point below that timing in Mathcad isn't that accurate.

Fred

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-22-2014
02:46 PM

04-22-2014
02:46 PM

Re: Display Calculation Time, How?

Oops! Don't know why I thought time() would not be available in Prime. I should have known better as I now remember vagely an older thread where I implemented some timing routines for someone dealing with rather huge matrices in Prime (probably 2.0 at that time) and it showed that Prime was quite slower in execution than MC15 - at least without multithreading. It was also shown that built-in commands like stack and augment are much(!) slower than self written routines using loops (this applies to both Prime and real Mathcad).

And yes, timing in Mathcad isn't quite accurate but at least it can show a tendency.

I am not sure if we get a better accuracy by placing the loop differently. Anyway, the first try was a bit surprising:

What we see here seems to be that the overhead caused by the loop counter incrementing (in timer1()) is much smaller than the overhead caused by the call to time() and the subsequent assignment to tsum (in timer2()).

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-22-2014
03:48 PM

04-22-2014
03:48 PM

Re: Display Calculation Time, How?

By comparison, in years past I did quite a bit of function and subroutine timing with my HP-41CX calculator to optimize calculator programs and the results were very consistent from trial to trial. That's the beauty of a simple machine with all functions built into ROM. Of course, the functions were MUCH slower and timing precision was limited to 0.01 sec.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-22-2014
07:42 PM

04-22-2014
07:42 PM

Re: Display Calculation Time, How?

Here's a user DLL from Robert Adair that is more accurate than the time function. It does not work in Prime, but the cpp project is included, so someone could make a new DLL that would work with not too much effort.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-22-2014
08:52 PM

04-22-2014
08:52 PM

Re: Display Calculation Time, How?

Thanks a lot. Sure soemthing for my toolbox. Those routines at least deliver more consistent results when called multiple times and also the result is not dependent that much on the number of loops. The dll routines seem to have more overhead, though, as the times measured are generally larger than those measured with the built-in time().

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-21-2014
10:26 PM

04-21-2014
10:26 PM

If we construct a function (calculation time to solve system vs. number of unknown) we see, if we plot in in a log-log scale that it looks approx. like a straight line. Timing in Mathcad isn't that accurate and we don't know how to compensate for time to function call and looping.

So it seems to be a good idea to try a powerfit

which show that the time is approx proportional to x^3.15 which may be x^3 for more precise timing!?

Also extrapolations using the powerfunction are quite good

Unfortuately Mathcad won't be able to deal with much larger matrices than 4000x4000 but the tendency is well seen anyway.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

04-29-2014
09:13 PM

04-29-2014
09:13 PM

Re: Display Calculation Time, How?

I ended up having to do my entire homework problem in Matlab. I don't particularly like Matlab, but for a problem like this it was so much easier. I don't know why mathcad has to make certain things so difficult.