aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Fernandez <matiasfmolinari@gmail.com>2023-05-09 16:43:26 -0400
committerMatias Fernandez <matiasfmolinari@gmail.com>2023-05-09 16:43:26 -0400
commit4e146a75b60a76482fc3e1d6c2d83476a7b23776 (patch)
treea8f448d093d6455567c4dc2200c6147dda37e7b0
parent9867037aa2a9adc93b2954f6bfab03b6db352a70 (diff)
Allow user to pass in scale directly in spall.context_create
-rw-r--r--core/prof/spall/spall.odin17
1 files changed, 12 insertions, 5 deletions
diff --git a/core/prof/spall/spall.odin b/core/prof/spall/spall.odin
index 5c00d16a1..19a05d70a 100644
--- a/core/prof/spall/spall.odin
+++ b/core/prof/spall/spall.odin
@@ -67,16 +67,15 @@ Buffer :: struct {
BUFFER_DEFAULT_SIZE :: 0x10_0000
-context_create :: proc(filename: string, freq_fallback_sleep := 2 * time.Second) -> (ctx: Context, ok: bool) #optional_ok {
+context_create_with_scale :: proc(filename: string, precise_time: bool, timestamp_scale: f64) -> (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_fallback_sleep)
- ctx.precise_time = freq_ok
- ctx.timestamp_scale = ((1 / f64(freq)) * 1_000_000) if freq_ok else 1
+ ctx.fd = fd
+ ctx.precise_time = precise_time
+ ctx.timestamp_scale = timestamp_scale
temp := [size_of(Manual_Header)]u8{}
_build_header(temp[:], ctx.timestamp_scale)
@@ -85,6 +84,14 @@ context_create :: proc(filename: string, freq_fallback_sleep := 2 * time.Second)
return
}
+context_create_with_sleep :: proc(filename: string, sleep := 2 * time.Second) -> (ctx: Context, ok: bool) #optional_ok {
+ freq, freq_ok := time.tsc_frequency(sleep)
+ timestamp_scale: f64 = ((1 / f64(freq)) * 1_000_000) if freq_ok else 1
+ return context_create_with_scale(filename, freq_ok, timestamp_scale)
+}
+
+context_create :: proc{context_create_with_scale, context_create_with_sleep}
+
context_destroy :: proc(ctx: ^Context) {
if ctx == nil {
return