Can the (time) procedure be improved??

74 views
Skip to first unread message

leonardo lv

unread,
Jul 12, 2021, 9:37:38 AM7/12/21
to Racket Developers
Hi All,

Whether the (time) procedure can be similar to Chez Scheme, when printing the time consumed by expressions, it also prints out how many bytes are allocated, which is very beneficial for debugging and optimization.

19 collections

    0.201254290s elapsed cpu time, including 0.183228711s collecting

    0.201678000s elapsed real time, including 0.183665000s collecting

    160012160 bytes allocated, including 113015168 bytes reclaimed


Matthew Flatt

unread,
Jul 21, 2021, 9:20:33 AM7/21/21
to leonardo lv, Racket Developers
I don't think we can change the `time` form from `racket/base` without
breaking existing uses. For better or worse, various scripts parse the
output, especially since the output format has been stable.

But there's nothing special about the pre-defined `time` form. A new
form could use `time-apply` plus `current-memory-use` --- or even
functions like `current-inexact-monotonic-milliseconds` and
`current-gc-milliseconds instead of `time-apply` --- to get information
to display.

At Mon, 12 Jul 2021 06:37:38 -0700 (PDT), leonardo lv wrote:
> Hi All,
>
> Whether the (time) procedure can be similar to Chez Scheme, when printing
> the time consumed by expressions, it also prints out how many bytes are
> allocated, which is very beneficial for debugging and optimization.
>
> * 19 collections 0.201254290s elapsed cpu time, including 0.183228711s
> collecting 0.201678000s elapsed real time, including 0.183665000s
> collecting 160012160 bytes allocated, including 113015168 bytes
> reclaimed*

leonardo lv

unread,
Jul 22, 2021, 3:52:43 AM7/22/21
to Racket Developers

yes, I agree. The same goal can be achieved by combining these functions, thanks for your reply.
Reply all
Reply to author
Forward
0 new messages