add with-timing macro to see why it's slow
This commit is contained in:
parent
4aa140c264
commit
988a30801b
@ -1,5 +1,6 @@
|
||||
; (local { : view } (require :fennel))
|
||||
(local { : fdopen } (require :posix.stdio))
|
||||
(local ptime (require :posix.time))
|
||||
(local cqueues (require :cqueues))
|
||||
|
||||
(local nmea (require :nmea))
|
||||
@ -7,6 +8,17 @@
|
||||
|
||||
(import-macros { : define-tests : expect : expect= } :assert)
|
||||
|
||||
(macro with-timing [label & body]
|
||||
`(let [before# (ptime.clock_gettime ptime.CLOCK_PROCESS_CPUTIME_ID)
|
||||
ret# (table.pack (do ,body))]
|
||||
(let [after# (ptime.clock_gettime ptime.CLOCK_PROCESS_CPUTIME_ID)]
|
||||
(print ,label (.. (- after#.tv_sec before#.tv_sec) "s "
|
||||
(// (- after#.tv_nsec before#.tv_nsec) 1000) "us "))
|
||||
(table.unpack ret#))))
|
||||
|
||||
; (with-timing :loop (for [i 1 100] (print i)))
|
||||
|
||||
|
||||
(local {
|
||||
: Gtk
|
||||
: Gdk
|
||||
|
Loading…
Reference in New Issue
Block a user