Module for measuring execution speed.
- Download Benchmark.mqh
- Save the file to /MQL4/Include/mql4_modules/Benchmark/Benchmark.mqh
- Include Benchmark.mqh.
- Execute the Start method before the processing you want to measure.
- Execute the End method after the processing you want to measure.
- Elapsed time is output to the Experts tab.
#include <Benchmark.mqh>
int OnInit()
{
// Start measurement.
Benchmark::Start("Sample");
for(int i = 0; i < 1000000; i++) {
// Some processing.
}
// End measurement.
Benchmark::End();
return(INIT_SUCCEEDED);
}
Instead of running the Start and End methods, you can also use BenchmarkRun.
int sum(int a, int b, int c)
{
return(a + b + c);
}
int OnInit()
{
// Output the time taken to execute the function sum one million times.
BenchmarkRun(sum(100, 200, 300), 1000000);
return(INIT_SUCCEEDED);
}