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:
-timeto get time metrics-energy <option>where option can be:"mock"to turn on the mock observer."power:<ip>:<port>"to turn on the smartpower observer onip:port.
-signalto insert a signal handler-path <path>to specify a new path where to export the report.-lwt-contextto add aLwt_main.runwhen needed to ensureLwtpromises are executed because in a nonLwtprogram. /!\ Don't use it if you are already in anLwtcontext.
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;
varwhere 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 */
]
}
}
]