-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtime.tem
42 lines (42 loc) · 2.46 KB
/
time.tem
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
(page "Time"
(import "docs/time0.html")
(newtable "Time"
(def date "[time]" "Displays the specified date (or current date by default). This works only on Unix-like systems." (faketest "(date)" "2008-02-20"))
(op seconds " " "Returns current time in seconds, from a platform-specific
starting date." (tests (seconds)))
(op msec "" "Returns current time in milliseconds. The time is from an
arbitrary starting date, and can wrap or be negative."
(tests (msec)))
(op timedate "[secs]" "Converts time to string; default is current time. New in arc3."
(tests (timedate) (timedate 0)))
(op current-gc-milliseconds " " "Returns the amount of time spent in garbage
collection."
(tests (current-gc-milliseconds)))
(op current-process-milliseconds "" "Returns the number of milliseconds of
processor time used."
(tests (current-process-milliseconds)))
(def since "t0" "Displays the number of seconds since <code>t0</code>. The base time <code>t0</code> should come from <code>seconds</code>."
(tests (let t0 (seconds) (sleep 1) (since t0))))
(def minutes-since "t0" "Displays number of minutes since <code>t0</code>. New in arc3."
(tests (let t0 (seconds) (sleep 1) (minutes-since t0))))
(def hours-since "t0" "Displays number of hours since <code>t0</code>."
(tests (let t0 (seconds) (sleep 1) (hours-since t0))))
(def days-since "t0" "Displays number of days since <code>t0</code>."
(tests (let t0 (seconds) (sleep 1) (days-since t0))))
(def datestring "[secs]" "Creates a date string from the current time or given seconds. New in arc3." (tests (datestring) (datestring 0)))
)
(newtable "Timing"
(mac time "expr" "Executes <code>expr</code> and prints how long it took to execute."
(tests (time (sleep .1))))
(mac jtime "expr" "Executes <code>expr</code>, prints how long it took to execute, and returns the symbol <code>ok</code>."
(tests (jtime (sleep .1))))
(mac time10 "expr" "Executes <code>expr</code> 10 times and prints how long it took in total to execute." (tests (time10 (sleep .1))))
)
(newtable "Cache"
(def cache "timef valf" "Returns a caching procedure. <code>timef</code> is a function that returns the cache lifetime in seconds. <code>valf</code> is a function that returns the value to be cached." (tests
(cache (fn () 5) (fn () "val"))
))
(mac defcache "name lasts [body ...]" "Assigns a caching procedure to variable name. lasts is the cache lifetime in seconds. The body code returns the value to be cached. New in arc3." (tests
(defcache foo 300 "val")))
)
)