package core:prof/spall

⌘K
Ctrl+K
or
/

    Overview

    import "core:prof/spall"

    spall_ctx: spall.Context
    spall_buffer: spall.Buffer
    
    foo :: proc() {
    	spall.SCOPED_EVENT(&spall_ctx, &spall_buffer, #procedure)
    }
    
    main :: proc() {
    	spall_ctx = spall.context_create("trace_test.spall")
    	defer spall.context_destroy(&spall_ctx)
    
    	buffer_backing := make([]u8, spall.BUFFER_DEFAULT_SIZE)
    	spall_buffer = spall.buffer_create(buffer_backing)
    	defer spall.buffer_destroy(&spall_ctx, &spall_buffer)
    
    	spall.SCOPED_EVENT(&spall_ctx, &spall_buffer, #procedure)
    
    	for i := 0; i < 9001; i += 1 {
    		foo()
    	}
    }
    
    // Automatic profiling of every procedure:
    
    @(instrumentation_enter)
    spall_enter :: proc "contextless" (proc_address, call_site_return_address: rawptr, loc: runtime.Source_Code_Location) {
    	spall._buffer_begin(&spall_ctx, &spall_buffer, "", "", loc)
    }
    
    @(instrumentation_exit)
    spall_exit :: proc "contextless" (proc_address, call_site_return_address: rawptr, loc: runtime.Source_Code_Location) {
    	spall._buffer_end(&spall_ctx, &spall_buffer)
    }
    

    Types

    Begin_Event ¶

    Begin_Event :: struct #packed {
    	type:     Manual_Event_Type,
    	category: u8,
    	pid:      u32le,
    	tid:      u32le,
    	ts:       f64le,
    	name_len: u8,
    	args_len: u8,
    }

    Buffer ¶

    Buffer :: struct {
    	data: []u8,
    	head: int,
    	tid:  u32,
    	pid:  u32,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    Context ¶

    Context :: struct {
    	precise_time:    bool,
    	timestamp_scale: f64,
    	fd:              os.Handle,
    }
    Related Procedures With Parameters
    Related Procedures With Returns

    End_Event ¶

    End_Event :: struct #packed {
    	type: Manual_Event_Type,
    	pid:  u32le,
    	tid:  u32le,
    	ts:   f64le,
    }

    Manual_Event_Type ¶

    Manual_Event_Type :: enum u8 {
    	Invalid  = 0, 
    	Begin    = 3, 
    	End      = 4, 
    	Instant  = 5, 
    	Pad_Skip = 7, 
    }

    Manual_Header ¶

    Manual_Header :: struct #packed {
    	magic:           u64le,
    	version:         u64le,
    	timestamp_scale: f64le,
    	reserved:        u64le,
    }

    Pad_Skip ¶

    Pad_Skip :: struct #packed {
    	type: Manual_Event_Type,
    	size: u32le,
    }

    Constants

    BEGIN_EVENT_MAX ¶

    BEGIN_EVENT_MAX :: size_of(Begin_Event) + 255 + 255

    BUFFER_DEFAULT_SIZE ¶

    BUFFER_DEFAULT_SIZE :: 0x10_0000

    MANUAL_MAGIC ¶

    MANUAL_MAGIC :: u64le(0x0BADF00D)

    Variables

    This section is empty.

    Procedures

    SCOPED_EVENT ¶

    SCOPED_EVENT :: proc(ctx: ^Context, buffer: ^Buffer, name: string, args: string = "", location := #caller_location) -> bool {…}

    buffer_create ¶

    buffer_create :: proc(data: []u8, tid: u32 = 0, pid: u32 = 0) -> (buffer: Buffer, ok: bool) #optional_ok {…}

    buffer_destroy ¶

    buffer_destroy :: proc(ctx: ^Context, buffer: ^Buffer) {…}

    buffer_flush ¶

    buffer_flush :: proc "contextless" (ctx: ^Context, buffer: ^Buffer) {…}

    context_create_with_scale ¶

    context_create_with_scale :: proc(filename: string, precise_time: bool, timestamp_scale: f64) -> (ctx: Context, ok: bool) #optional_ok {…}

    context_create_with_sleep ¶

    context_create_with_sleep :: proc(filename: string, sleep: time.Duration = 2 * time.Second) -> (ctx: Context, ok: bool) #optional_ok {…}

    context_destroy ¶

    context_destroy :: proc(ctx: ^Context) {…}

    tick_now ¶

    tick_now :: proc "contextless" () -> (ns: i64) {…}

    write ¶

    write :: proc "contextless" (fd: os.Handle, buf: []u8) -> (n: int, err: os.Errno) {…}

    Procedure Groups

    Source Files

    Generation Information

    Generated with odin version dev-2024-04 (vendor "odin") Windows_amd64 @ 2024-04-26 21:08:58.623397100 +0000 UTC