janet-lang / spork

Various Janet utility modules - the official "Contrib" library.
MIT License
122 stars 35 forks source link

Add timeit-loop #128

Closed primo-ppcg closed 1 year ago

primo-ppcg commented 1 year ago

Related issue: #127

Adds a function which extends loop to output performance statistics after completion.

Sample usage:

(def ind (range 1000))
(timeit-loop [:timeout 1] "take" (take -500 ind))
(timeit-loop [:timeout 1] "drop" (drop 500 ind))
# ->
take 1.000s, 1.514µs/body
drop 1.000s, 1.496µs/body