aboutsummaryrefslogtreecommitdiff
path: root/core/prof
diff options
context:
space:
mode:
authorMatias Fernandez <matiasfmolinari@gmail.com>2023-05-09 00:03:58 -0400
committerMatias Fernandez <matiasfmolinari@gmail.com>2023-05-09 00:03:58 -0400
commit57c14f6a9bfcf57ee598dcf8dedcc3f753535726 (patch)
treeff91e5ea010c2509d785b7025d43deb86620013d /core/prof
parent1ed105205c23910b8f017fa8de09caca29a3781f (diff)
Allow custom sleep on tsc fallback.
This gives the user more control over the spectrum of precision vs. load time on Windows. Spall's output with much lower sleep times is still useful in my experience. NOTE: A better API might be to allow the user to pass the freq as a param to "create_context" in case they already paid for it beforehand, but this seems fine for now.
Diffstat (limited to 'core/prof')
-rw-r--r--core/prof/spall/spall.odin4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/prof/spall/spall.odin b/core/prof/spall/spall.odin
index 6a78c466e..5c00d16a1 100644
--- a/core/prof/spall/spall.odin
+++ b/core/prof/spall/spall.odin
@@ -67,14 +67,14 @@ Buffer :: struct {
BUFFER_DEFAULT_SIZE :: 0x10_0000
-context_create :: proc(filename: string) -> (ctx: Context, ok: bool) #optional_ok {
+context_create :: proc(filename: string, freq_fallback_sleep := 2 * time.Second) -> (ctx: Context, ok: bool) #optional_ok {
fd, err := os.open(filename, os.O_WRONLY | os.O_APPEND | os.O_CREATE | os.O_TRUNC, 0o600)
if err != os.ERROR_NONE {
return
}
ctx.fd = fd
- freq, freq_ok := time.tsc_frequency()
+ freq, freq_ok := time.tsc_frequency(freq_fallback_sleep)
ctx.precise_time = freq_ok
ctx.timestamp_scale = ((1 / f64(freq)) * 1_000_000) if freq_ok else 1