From 988a30801b615a0aa9c4bac515cabfdaeb1ec90a Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Mon, 9 Jun 2025 22:05:38 +0100 Subject: [PATCH] add with-timing macro to see why it's slow --- pkgs/maps/main.fnl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkgs/maps/main.fnl b/pkgs/maps/main.fnl index 2a1183f..41fdc16 100644 --- 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