[PATCH] make number of printed digits of ')time' configurable

3 views
Skip to first unread message

Qian Yun

unread,
Dec 1, 2023, 8:36:04 PM12/1/23
to fricas-devel
With this patch, the number of digits to be printed in ')time'
output is now configurable via:

)boot $timePrintDigits := 3

As we discussed before, this could be useful -- and after a
few days testing, it is useful.

- Qian

diff --git a/src/interp/g-timer.boot b/src/interp/g-timer.boot
index 326cf2d4..8fc2aa35 100644
--- a/src/interp/g-timer.boot
+++ b/src/interp/g-timer.boot
@@ -48,7 +48,7 @@ makeLongStatStringByProperty _
PUT(cl, classproperty, n + GET(cl, classproperty))
total := total + n
name = 'other or flag ~= 'long => 'iterate
- if n >= 0.01 then
+ if significantStat? n then
str := makeStatString(str, n, name, flag)
else
insignificantStat := insignificantStat + n
@@ -64,18 +64,21 @@ makeLongStatStringByProperty _

normalizeStatAndStringify t ==
FLOATP t =>
- t < 0.01 => '"0"
- FORMAT(nil,'"~,2F",t)
+ not significantStat? t => '"0"
+ fmtStr := STRCONC('"~,", STRINGIMAGE $timePrintDigits, '"F")
+ FORMAT(nil, fmtStr, t)
INTEGERP t => FORMAT(nil, '"~:d", t)
STRINGIMAGE t

makeStatString(oldstr,time,abb,flag) ==
- time < 0.01 => oldstr
+ not significantStat? time => oldstr
opening := (flag = 'long => '"("; '" (")
timestr := normalizeStatAndStringify time
oldstr = '"" => STRCONC(timestr, opening, abb, '")")
STRCONC(oldstr, '" + ", timestr, opening, abb, '")")

+significantStat? t == t >= 0.1^$timePrintDigits
+
peekTimedName() == IFCAR $timedNameStack

popTimedName() ==
@@ -100,6 +103,7 @@ stopTimingProcess name ==
DEFPARAMETER($oldElapsedSpace, 0)
DEFPARAMETER($oldElapsedGCTime, 0.0)
DEFPARAMETER($oldElapsedTime, 0.0)
+DEFPARAMETER($timePrintDigits, 2)

-- $timedNameStack is used to hold the names of sections of the
-- code being timed.

Waldek Hebisch

unread,
Dec 1, 2023, 11:35:05 PM12/1/23
to fricas...@googlegroups.com
On Sat, Dec 02, 2023 at 09:36:01AM +0800, Qian Yun wrote:
> With this patch, the number of digits to be printed in ')time'
> output is now configurable via:
>
> )boot $timePrintDigits := 3
>
> As we discussed before, this could be useful -- and after a
> few days testing, it is useful.

OK.

--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages