biscuit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 988a30801b615a0aa9c4bac515cabfdaeb1ec90a
parent 4aa140c264412c5c2da9dc13215523371ba622ff
Author: Daniel Barlow <dan@telent.net>
Date:   Mon,  9 Jun 2025 22:05:38 +0100

add with-timing macro to see why it's slow

Diffstat:
Mpkgs/maps/main.fnl | 12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/pkgs/maps/main.fnl b/pkgs/maps/main.fnl @@ -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