Tilde Friends
Performance Tracing

Typedefs

typedef struct _tf_trace_t tf_trace_t
 
typedef struct sqlite3 sqlite3
 
typedef void() tf_trace_write_callback_t(tf_trace_t *trace, const char *buffer, size_t size, void *user_data)
 

Functions

tf_trace_ttf_trace_create ()
 
void tf_trace_destroy (tf_trace_t *trace)
 
void tf_trace_set_process_name (tf_trace_t *trace, const char *name)
 
void tf_trace_counter (tf_trace_t *trace, const char *name, int argc, const char **arg_names, const int64_t *arg_values)
 
void tf_trace_begin (tf_trace_t *trace, const char *name)
 
void tf_trace_end (tf_trace_t *trace)
 
char * tf_trace_export (tf_trace_t *trace)
 
void tf_trace_set_write_callback (tf_trace_t *trace, tf_trace_write_callback_t *callback, void *user_data)
 
void tf_trace_raw (tf_trace_t *trace, const char *buffer, size_t size)
 
void tf_trace_sqlite (tf_trace_t *trace, sqlite3 *sqlite)
 

Detailed Description

Generates trace output that is compatible with speedscope.app, chrome://tracing or ui.perfetto.dev for scrutinizing what each thread is doing for optimization purposes.

Typedef Documentation

◆ sqlite3

typedef struct sqlite3 sqlite3

An SQLite database instance.

◆ tf_trace_t

typedef struct _tf_trace_t tf_trace_t

A trace instance.

◆ tf_trace_write_callback_t

typedef void() tf_trace_write_callback_t(tf_trace_t *trace, const char *buffer, size_t size, void *user_data)

A callback to collect trace data.

Parameters
traceThe trace instance.
bufferThe trace data.
sizeThe size of the trace data.
user_dataUser data registered with the callback.

Function Documentation

◆ tf_trace_begin()

void tf_trace_begin ( tf_trace_t trace,
const char *  name 
)

Begin tracing a time interval. End with tf_trace_end().

Parameters
traceThe trace instance.
nameThe interval name.

◆ tf_trace_counter()

void tf_trace_counter ( tf_trace_t trace,
const char *  name,
int  argc,
const char **  arg_names,
const int64_t *  arg_values 
)

Record counter values.

Parameters
traceThe trace instance.
nameThe counter group name.
argcThe number of counters.
arg_namesThe counter names.
arg_valuesThe counter values.

◆ tf_trace_create()

tf_trace_t * tf_trace_create ( )

Create a trace instance. Can be used to produce a Chrome trace event document for analyzing performance. Clean up with tf_trace_destroy().

Returns
A trace instance.

◆ tf_trace_destroy()

void tf_trace_destroy ( tf_trace_t trace)

Destroy a trace instance that was created with tf_trace_create().

◆ tf_trace_end()

void tf_trace_end ( tf_trace_t trace)

End tracing the next time interval previously started with tf_trace_begin().

Parameters
traceThe trace instance.

◆ tf_trace_export()

char * tf_trace_export ( tf_trace_t trace)

Export all currently stored trace data to a string.

Parameters
traceThe trace instance.
Returns
A string representation of the trace data.

◆ tf_trace_raw()

void tf_trace_raw ( tf_trace_t trace,
const char *  buffer,
size_t  size 
)

Inject raw trace data.

Parameters
traceThe trace instance.
bufferThe trace data.
sizeThe size of the trace data.

◆ tf_trace_set_process_name()

void tf_trace_set_process_name ( tf_trace_t trace,
const char *  name 
)

Set the name of the current process.

Parameters
traceThe trace instance.
nameThe name of the process.

◆ tf_trace_set_write_callback()

void tf_trace_set_write_callback ( tf_trace_t trace,
tf_trace_write_callback_t callback,
void *  user_data 
)

Replace the trace recording behavior.

Parameters
traceThe trace instance.
callbackA callback that will be called instead of collecting the trace data in a buffer.
user_dataUser data to pass to the callback.

◆ tf_trace_sqlite()

void tf_trace_sqlite ( tf_trace_t trace,
sqlite3 sqlite 
)

Register for trace-worthy events from sqlite and record them going forward.

Parameters
traceThe trace instance.
sqliteThe SQLite database.