Ppx-tezos_oxymeter

The ppx-tezos_oxymeter is a tool that relies on Tezos_oxymeter to gather information about energy and time consumption. Its goal is to instrument the code easily and export the result as a report in JSON.

Code instrumentation

To instrument the code, you can describe the functions you want to select in a specific file thanks to a JSON:

{
  "path/filename.ml": [
    "function_1",
    "function_2",
    ...
  ],
  "path/filename.ml": [
    "function_n",
    ...
  ]
}

Where the path is the one from the dune-project file. Indeed, this ppx relies on the dune to locate itself. The default file the ppx is about to check is ./metrics_config.json. You can specific another file thanks to the variable METRICS_CONFIG_PATH.

Arguments

When you instrument your dune with the ppx, you can pass several options:

Behaviour

The instrumentation of the code while result in the following modification of your code:

XMetrics.insert file.ml fun `Start;
let var= fun () in
XMetrics.insert file.ml fun `Stop;
var

where X is ether a Tezos_oxymeter.Metrics.TimeMetrics or a Tezos_oxymeter.Metrics.EnergyMetrics.

It will also insert a piece of code in the header to build the report on signal (SIGUSR1) or when the program exits.

Report

This will generate a report in /tmp/oxymeter-report/ where the report is a JSON. An example of a generated report for the time metrics is:

[
 {
    "hello_file.ml": {
      "hello": [
        5.000241994857788 /* in seconds */
      ]
    }
 }
]