Jai bindings for the Tracy profiler v0.11.1
It’s originally based on vrcamillo/jai-tracy, but modified to work as an auto-instrumenting metaprogram plugin (like modules/Iprof).
- Ensure that the
tracy
submodule is cloned at the root of the repository. - Build the static and shared libraries using
jai generate.jai
at the root of the repository.
This only works if your project does not contain a custom metaprogram! (i.e. you never call set_build_options_dc({do_output = false})
) Otherwise see below.
- Just use this module as a metaprogram plugin by adding
-pluging tracy
to your compile command. (Assuming that you have cloned this repo into a folder namedtracy
.) - If you want to profile modules code (in addition to your application code) you can append the argument
-modules
.
You might need to add -- import_dir <path_to_modules_folder_that_contains_tracy>
if this module does not live in your default modules folder.
If your program has its own metaprogram, you need to add this plugin to your metaprogram, which involves…
- adding
#import "Metaprogram_Plugins"
, - calling
Metaprogram_Plugins.init_plugins(…)
, - calling the plugin’s
before_intercept
,add_source
, etc. at the appropriate time.
Take a look at Default_Metaprogram
for how to support plugins.
You can even use this plugin to profile your compile-time metaprogram, #run commands, etc. But it requires some inception-style work:
- Tell the compile to use the Default_Metaprogram with the tracy plugin to compile … the Default_Metaprogram.
- Then use that second Default_Metaprogram to compile your project.
It looks something like this:
jai <path_to_jai>/modules/Default_Metaprogram.jai -plug tracy -modules -no_cwd \ # Compile Default_Metaprogram with the tracy plugin
- <your_normal_entry_file>.jai <your normal compile arguments> \ # Arguments for the second-stage Default_Metaprogram, which is what you would normally pass to the compiler/metaprogram
-- import_dir <path_to_modules_folder_that_contains_tracy> # Add this if you need to tell the first-stage Default_Metaprogram where to find the tracy module.
Tracy is released under the 3-clause BSD license.
These bindings are released under the MIT license.
You can find more detailed information in Tracy documentation, available in the official repository.