Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Instrument C/C++ with -finstrument-functions for execution tracing and Perfetto visualisation
| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-08 | ✗→✓ | ▲ Improved | -21% | 0% |
| case-01 | ✗→✓ | ▲ Improved | -9% | 0% |
| case-02 | ✗→✓ | ▲ Improved | -10% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 61% | 0% |
| case-13 | ✗→✓ | ▲ Improved | -6% | 0% |
Trace all function calls in C/C++ programs with per-thread logs and Perfetto visualization.
Captures function entry/exit, writes per-thread logs.
Build:
bashgcc -c -fPIC trace_instrument.c -o trace_instrument.o gcc -shared trace_instrument.o -o libtrace.so -ldl -lpthread
Converts logs to Chrome JSON for Perfetto UI.
Build:
bashg++ -O3 -std=c++17 trace_to_perfetto.cpp -o trace_to_perfetto
makefileCFLAGS += -finstrument-functions -g LDFLAGS += -L. -ltrace -ldl -lpthread
bashmake
bashexport LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH ./program # Creates trace_<tid>.log files
bash./trace_to_perfetto trace_*.log -o trace.json # Open trace.json in ui.perfetto.dev
[seq] [timestamp] [dots] [ENTRY|EXIT!] function_name
[0] [1.000000000] [ENTRY] main
[1] [1.000050000] . [ENTRY] helper
[2] [1.000100000] . [EXIT!] helper
[3] [1.000150000] [EXIT!] maintrace_instrument.c and trace_to_perfetto.cpp to project-finstrument-functions to CFLAGS-L. -ltrace -ldl -lpthread to LDFLAGSLD_LIBRARY_PATH and run./trace_to_perfetto trace_*.log -o trace.jsonMakefile: Add flags conditionally
makefileENABLE_TRACE ?= 0 ifeq ($(ENABLE_TRACE),1) CFLAGS += -finstrument-functions -g LDFLAGS += -L. -ltrace -ldl -lpthread endif
CMake: Add option
cmakeoption(ENABLE_TRACE "Enable tracing" OFF) if(ENABLE_TRACE) add_compile_options(-finstrument-functions -g) link_libraries(trace dl pthread) endif()
Function ENTRY → "B" (begin) event Function EXIT! → "E" (end) event All threads aligned by timestamp in single file.
Other measured skills in the registry, with their headline benchmark lift.