rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

recursive calls not correctly accounted in timing #2150

Open rtoy opened 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-05 19:40:33 Created by robert_dodier on 2003-12-14 17:54:33 Original: https://sourceforge.net/p/maxima/bugs/471


TIMER_INFO gets units of time mixed up -- in the example below, should show 0.25 seconds instead of 25 seconds; setting TIMER_DEVALUE:TRUE before calling FF(200) makes the time come out as 0.25 seconds as expected.

Note that the time reported for GG is 25 seconds while the time for FF is 0.25 seconds -- the two should be identical or nearly so.

See also bug report #572835 ("timer_info gives incorrect time").

Maxima 5.9.0 cvs version of 20031128, clisp 2.31, redhat linux 7.1 (kernel 2.4.2).

--- begin example about timing_info --- (C1) GG(n):=if equal(n,0) then 0 else n+GG(n-1); (D1) GG(n) := IF EQUAL(n, 0) THEN 0 ELSE n + GG(n - 1) (C2) FF(n):=GG(n); (D2) FF(n) := GG(n) (C3) timer(FF,GG); (D3) [FF, GG] (C4) timer_info(); [ FUNCTION TIME//CALL CALLS RUNTIME GCTIME ] [
] [ GG 0 0 0
0 ] (D4) [
] [ FF 0 0 0
0 ] [
] [ TOTAL 0 0 0
0 ] (C5) FF(200); (D5) 20100 (C6) timer_info(); [ FUNCTION TIME//CALL CALLS
RUNTIME GCTIME ] [
] [ GG .1262686567164179 SEC 201
25.38 SEC 0 ] (D6) [
] [ FF 0.25 SEC 1 0.25 SEC 0 ] [
] [ TOTAL .1268811881188119 SEC 202
25.63 SEC 0 ] --- end example about timing_info ---

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-05 19:40:33 Created by crategus on 2009-11-03 22:09:05 Original: https://sourceforge.net/p/maxima/bugs/471/#69c0


I think we have no longer a problem with the function timer_info. The time per call for the reported example is not very accurate, but the values are sumed correctly.

(%i3) GG(n):=if equal(n,0) then 0 else GG(n-1)+n (%i4) FF(n):=GG(n) (%i5) timer(FF,GG) (%i6) FF(500) (%i7) timer_info() (%o7) matrix([function,time\/\/call,calls,runtime,gctime], [GG,.07129367864271456*sec,501,35.718133*sec,0], [FF,0.144009*sec,1,0.144009*sec,0], [total,.07143852988047808*sec,502,35.862142*sec,0])

This is an example for a function which needs much more time:

(%i8) ff(x):=block([fpprec:x],gamma_incomplete(5.0b-1,1.0b0),done)

The first call is needed to initialize internal values:

(%i9) ff(1024) (%i10) untimer(FF,GG) (%i11) timer(ff)

On my (slow) computer the function needs about 2.7 seconds per call. This is displayed correctly:

(%i12) ff(1024) (%i13) timer_info() (%o13) matrix([function,time\/\/call,calls,runtime,gctime], [ff,2.684167*sec,1,2.684167*sec,0], [total,2.684167*sec,1,2.684167*sec,0])

Further calls are added up correctly:

(%i14) ff(1024) (%i15) timer_info() (%o15) matrix([function,time\/\/call,calls,runtime,gctime], [ff,2.708169*sec,2,5.416338*sec,0], [total,2.708169*sec,2,5.416338*sec,0]) (%i16) ff(1024) (%i17) timer_info() (%o17) matrix([function,time\/\/call,calls,runtime,gctime], [ff,2.654832333333333*sec,3,7.964497*sec,0], [total,2.654832333333333*sec,3,7.964497*sec,0])

Setting the status to "pending" and "works for me".

Dieter Kaiser

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-05 19:40:37 Created by crategus on 2009-11-03 22:09:09 Original: https://sourceforge.net/p/maxima/bugs/471/#1e30


rtoy commented 4 months ago

Imported from SourceForge on 2024-07-05 19:40:40 Created by sf-robot on 2009-11-18 02:20:24 Original: https://sourceforge.net/p/maxima/bugs/471/#ffb6


rtoy commented 4 months ago

Imported from SourceForge on 2024-07-05 19:40:44 Created by sf-robot on 2009-11-18 02:20:24 Original: https://sourceforge.net/p/maxima/bugs/471/#cc32


This Tracker item was closed automatically by the system. It was previously set to a Pending status, and the original submitter did not respond within 14 days (the time period specified by the administrator of this Tracker).

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-05 19:40:47 Created by robert_dodier on 2010-06-22 16:35:48 Original: https://sourceforge.net/p/maxima/bugs/471/#22f6


rtoy commented 4 months ago

Imported from SourceForge on 2024-07-05 19:40:51 Created by robert_dodier on 2010-06-22 19:01:13 Original: https://sourceforge.net/p/maxima/bugs/471/#5531


rtoy commented 4 months ago

Imported from SourceForge on 2024-07-05 19:40:54 Created by robert_dodier on 2010-06-22 19:01:13 Original: https://sourceforge.net/p/maxima/bugs/471/#3187


Looks like problem was misidentified before, therefore changing summary.