EA31337 framework for writing trading robots for MetaTrader 4 and 5 platforms.
Type | Status |
---|---|
Travis CI build | |
AppVeyor build |
.
|-- Account (Orders)
|-- Terminal (Log)
| |-- SymbolInfo
| | |-- Market
| | | |-- Chart
| | | | |-- Draw
| | | | |-- Indicator
| |-- Tester
| |-- Session
| | |-- Check
| | |-- Registry
| | |-- RegistryBinary
| | |-- File
|-- Trade (Account, Chart, Log)
|-- Order (Market)
|-- Strategy (String, Trade)
|-- Indicators
|-- Strategies
|-- Rules (Condition, Action)
|-- Array
|-- DateTime
|-- BasicTrade
|-- Convert
|-- Inet
|-- MD5
|-- MQL4
|-- Mail
|-- Math
|-- Misc
|-- Msg
|-- Report
|-- SVG
|-- SetFile
|-- Stats
|-- SummaryReport
|-- Task
|-- Tests
|-- Ticker
|-- Timer (Object)
The purpose of Profiler
class is to profile functions by measuring its time of execution. The minimum threshold can be set, so only slow execution can be reported.
Example to measure execution of function multiple times, then printing the summary of all calls which took 5ms or more.
#include "Profiler.mqh"
void MyFunction() {
PROFILER_START
Sleep(rand()%10);
PROFILER_STOP
}
int OnInit() {
for (uint i = 0; i < 10; i++) {
MyFunction();
}
// Set minimum threshold of 5ms.
PROFILER_SET_MIN(5)
// Print summary of slow executions above 5ms.
PROFILER_PRINT
return (INIT_SUCCEEDED);
}
void OnDeinit(const int reason) {
PROFILER_DEINIT
}
Example to measure execution of function multiple times, then automatically printing all calls which took 5ms or more.
#include "Profiler.mqh"
void MyFunction() {
PROFILER_START
Sleep(rand()%10);
// Automatically prints slow executions.
PROFILER_STOP_PRINT
}
int OnInit() {
// Set minimum threshold of 5ms.
PROFILER_SET_MIN(5);
for (uint i = 0; i < 10; i++) {
MyFunction();
}
return (INIT_SUCCEEDED);
}
void OnDeinit(const int reason) {
PROFILER_DEINIT
}
The purpose ofTimer
class is to measure time between starting and stopping points.
Single timer:
#include "Timer.mqh"
Timer *timer = new Timer("mytimer");
timer.Start();
// Some code to measure here.
timer.Stop();
Print("Time (ms): ", timer.GetSum());
timer.PrintSummary();
delete timer;
Multiple measurements:
#include "Timer.mqh"
Timer *timer = new Timer(__FUNCTION__);
for (uint i = 0; i < 5; i++) {
timer.Start();
Sleep(10); // Some code to measure here.
PrintFormat("Current time elapsed before stop (%d/5): %d", i + 1, timer.GetTime());
timer.Stop();
PrintFormat("Current time elapsed after stop (%d/5): %d", i + 1, timer.GetTime(i));
}
timer.PrintSummary();
delete timer;
- For bugs/features, raise a new issue at GitHub.
- Join our Telegram group and channel for support.