Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
22
Task/Time-a-function/Fennel/time-a-function.fennel
Normal file
22
Task/Time-a-function/Fennel/time-a-function.fennel
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(do ;;; Time a function
|
||||
|
||||
(fn time-function [fn-to=be-timed]
|
||||
(local start-time (os.clock))
|
||||
(fn-to=be-timed)
|
||||
(- (os.clock) start-time) ;;; execution time in seconds
|
||||
)
|
||||
|
||||
(fn delay [delta-t]
|
||||
(local end-time (+ (os.clock) delta-t))
|
||||
(while (< (os.clock) end-time)
|
||||
(var x 0)
|
||||
(for [i 1 100_000] (set x (+ x 1)))
|
||||
)
|
||||
)
|
||||
|
||||
(fn test-fn []
|
||||
(delay 1.234) ; sleep 1.234 seconds
|
||||
)
|
||||
|
||||
(print (time-function test-fn " seconds"))
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue