Zulip Chat Archive
Stream: general
Topic: dbg_trace timestamp milliseconds
Samuel Chassot (Aug 12 2025 at 20:30):
Hi everyone,
I am trying to improve performance of our program at runtime, and for that I would like to print in a dbg_trace (or elsewhere) the current time in milliseconds, to later perform analysis using them. Is there a proper way to do so?
I tried IO.monoMsNow, IO.Process.output { cmd := "date", args := #["+%s%3N"] } and other related things, but it is always printing 0, and I couldn't find why.
Thanks a lot :)
Henrik Böving (Aug 12 2025 at 20:35):
I would probably suggest to work with proper profiling tools instead
Samuel Chassot (Aug 12 2025 at 20:38):
I am, but with them I am loosing information like what are the arguments passed to a given function for a given call.
Henrik Böving (Aug 12 2025 at 20:42):
Well if your function is indeed in an IO compatible monad you should be able to use IO.monoMsNow and it should just print things, if it is then monoMsNow returning 0 is certainly a bug
Samuel Chassot (Aug 12 2025 at 20:44):
that's the thing, the function is already in an Except monad and I couldn't change the signature without introducing to much of a burden. I was using IO.monoMsNow with unsafe
Henrik Böving (Aug 12 2025 at 20:52):
If you do that the compiler can arbitrarily reorder the monoMsNow call, you will at least have to use the same continuation based trick that dbgTrace uses.
Samuel Chassot (Aug 12 2025 at 21:38):
Henrik Böving said:
If you do that the compiler can arbitrarily reorder the monoMsNow call, you will at least have to use the same continuation based trick that dbgTrace uses.
Alright, that's what I suspected. Thank you!
Last updated: Dec 20 2025 at 21:32 UTC