core/prof/spall
spall
Types
9Begin_Event
Begin_Event :: struct #packed {
type: Manual_Event_Type,
ts: u64le,
name_len: u8,
args_len: u8,
}SourceBuffer
Buffer :: struct {
data: []u8,
head: int,
tid: u32,
pid: u32,
first_ts: u64,
}SourceContext
Context :: struct {
precise_time: bool,
timestamp_scale: f64,
file: ^os.File,
fd: uintptr,
}SourceUser Interface
End_Event
End_Event :: struct #packed {
type: Manual_Event_Type,
ts: u64le,
}SourceManual_Buffer_Header
Manual_Buffer_Header :: struct #packed {
size: u32le,
tid: u32le,
pid: u32le,
first_ts: u64le,
}SourceManual_Event_Type
Manual_Event_Type :: enum u8 {
Invalid = 0,
Begin = 3,
End = 4,
Instant = 5,
Pad_Skip = 7,
Name_Process = 8,
Name_Thread = 9,
}SourceManual_Stream_Header
Manual_Stream_Header :: struct #packed {
magic: u64le,
version: u64le,
timestamp_scale: f64le,
reserved: u64le,
}SourceName_Event
Name_Event :: struct #packed {
type: Manual_Event_Type,
name_len: u8,
}SourcePad_Skip
Pad_Skip :: struct #packed {
type: Manual_Event_Type,
size: u32le,
}SourceConstants
6BEGIN_EVENT_MAX
BEGIN_EVENT_MAX :: size_of(Begin_Event) + 255 + 255SourceBUFFER_DEFAULT_SIZE
BUFFER_DEFAULT_SIZE :: 0x10_0000SourceCLOCK_MONOTONIC_RAW
CLOCK_MONOTONIC_RAW :: 4SourceNOTE(tetra): "RAW" means: Not adjusted by NTP.
MANUAL_MAGIC
MANUAL_MAGIC :: u64le = u64le(0x0BADF00D)SourceFile Format
MAX_RW
MAX_RW :: 0x7fffffffSourceNAME_EVENT_MAX
NAME_EVENT_MAX :: size_of(Name_Event) + 255SourceProcedures
18SCOPED_EVENT
SCOPED_EVENT :: proc(ctx: ^Context, buffer: ^Buffer, name: string, args: string, location = #caller_location) -> (bool)Source_buffer_begin
_buffer_begin :: proc(ctx: ^Context, buffer: ^Buffer, name: string, args: string, location = #caller_location)Source_buffer_end
_buffer_end :: proc(ctx: ^Context, buffer: ^Buffer)Source_buffer_name_process
_buffer_name_process :: proc(ctx: ^Context, buffer: ^Buffer, name: string, location = #caller_location)Source_buffer_name_thread
_buffer_name_thread :: proc(ctx: ^Context, buffer: ^Buffer, name: string, location = #caller_location)Source_build_begin
_build_begin :: proc(buffer: []u8, name: string, args: string, ts: u64) -> (event_size: int, ok: bool)Source_build_end
_build_end :: proc(buffer: []u8, ts: u64) -> (event_size: int, ok: bool)Source_build_name_event
_build_name_event :: proc(buffer: []u8, name: string, type: Manual_Event_Type) -> (event_size: int, ok: bool)Source_build_stream_header
_build_stream_header :: proc(buffer: []u8, timestamp_scale: f64) -> (header_size: int, ok: bool)Source_tick_now
_tick_now :: proc() -> (ns: i64)Source_trace_now
_trace_now :: proc(ctx: ^Context) -> (u64)Source_write
_write :: proc(fd: uintptr, data: []u8)Sourcebuffer_create
buffer_create :: proc(data: []u8, tid: u32, pid: u32) -> (buffer: Buffer, ok: bool)Sourcebuffer_destroy
buffer_destroy :: proc(ctx: ^Context, buffer: ^Buffer)Sourcebuffer_flush
buffer_flush :: proc(ctx: ^Context, buffer: ^Buffer)Sourcecontext_create_with_scale
context_create_with_scale :: proc(filename: string, precise_time: bool, timestamp_scale: f64) -> (ctx: Context, ok: bool)Sourcecontext_create_with_sleep
context_create_with_sleep :: proc(filename: string, sleep = 2 * time.Second) -> (ctx: Context, ok: bool)Sourcecontext_destroy
context_destroy :: proc(ctx: ^Context)Source