add environment variable to enable profile stats collection
This commit is contained in:
parent
1486e5a9e0
commit
17e3e0397f
@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
(import-macros { : define-tests : expect : expect= } :assert)
|
(import-macros { : define-tests : expect : expect= } :assert)
|
||||||
|
|
||||||
|
(local profile
|
||||||
|
(and (os.getenv "IN_NIX_SHELL")
|
||||||
|
(require :libluaperf)))
|
||||||
|
|
||||||
(macro with-timing [label & body]
|
(macro with-timing [label & body]
|
||||||
`(let [before# (ptime.clock_gettime ptime.CLOCK_PROCESS_CPUTIME_ID)
|
`(let [before# (ptime.clock_gettime ptime.CLOCK_PROCESS_CPUTIME_ID)
|
||||||
ret# (table.pack (do ,body))]
|
ret# (table.pack (do ,body))]
|
||||||
@ -58,13 +62,17 @@ label.readout {
|
|||||||
)
|
)
|
||||||
(style_provider:load_from_data CSS)))
|
(style_provider:load_from_data CSS)))
|
||||||
|
|
||||||
|
(fn main-quit []
|
||||||
|
(when profile (profile:stop))
|
||||||
|
(Gtk.main_quit))
|
||||||
|
|
||||||
(local window (Gtk.Window {
|
(local window (Gtk.Window {
|
||||||
:title "Map"
|
:title "Map"
|
||||||
:name "toplevel"
|
:name "toplevel"
|
||||||
:default_width viewport-width
|
:default_width viewport-width
|
||||||
:default_height viewport-height
|
:default_height viewport-height
|
||||||
|
|
||||||
:on_destroy Gtk.main_quit
|
:on_destroy main-quit
|
||||||
}))
|
}))
|
||||||
|
|
||||||
(local state-widgets { })
|
(local state-widgets { })
|
||||||
@ -453,6 +461,15 @@ label.readout {
|
|||||||
true)
|
true)
|
||||||
nil nil)
|
nil nil)
|
||||||
|
|
||||||
|
(fn collect-profile []
|
||||||
|
(GLib.timeout_add
|
||||||
|
GLib.PRIORITY_DEFAULT
|
||||||
|
(* 60 1000) main-quit
|
||||||
|
nil nil)
|
||||||
|
(print "profiling for 60 seconds")
|
||||||
|
(profile.start 0))
|
||||||
|
|
||||||
|
|
||||||
(window:add
|
(window:add
|
||||||
(doto (Gtk.Overlay {})
|
(doto (Gtk.Overlay {})
|
||||||
(: :add (osm-widget))
|
(: :add (osm-widget))
|
||||||
@ -463,4 +480,5 @@ label.readout {
|
|||||||
|
|
||||||
(window:show_all)
|
(window:show_all)
|
||||||
(styles)
|
(styles)
|
||||||
|
(when (os.getenv "MAP_PROFILE") (collect-profile))
|
||||||
(Gtk:main)
|
(Gtk:main)
|
||||||
|
Loading…
Reference in New Issue
Block a user