MQLArticles/Utils/MBen/README.md
2026-09-06 11:15:27 -05:00

19 lines
886 B
Markdown

[← Utils](../README.md)
# Utils/MBen
Benchmarking helper for timing multiple code blocks/operations and persisting the results to a local SQLite database for later comparison.
## Main features
- Accumulate timing samples per operation/dataset in memory (`CMultiBenchmark::Add`).
- Flush all accumulated samples to a local SQLite database, creating the table if needed (`CMultiBenchmark::Finish`).
- Parse a previously generated `.log` file (with a `[MultiBen&` tagging convention) and flush its results to the database as well (`CMultiBenchmark::ParseLogFileTodayFlushDb`).
## Basic usage
```mql5
CMultiBenchmark::Add("parse_json", "dataset_1000", 1, elapsed_microseconds);
// ... repeat Add() for each iteration/operation ...
CMultiBenchmark::Finish("benchmarks.sqlite", TimeToString(TimeLocal(), TIME_DATE), "MyLib");
```
> Only the most representative methods are shown here.