forked from nique_372/MQLArticles
70 lines
2.2 KiB
MQL5
70 lines
2.2 KiB
MQL5
//+------------------------------------------------------------------+
| |
//| Test.mq5 |
| |
//| Copyright 2026, Niquel Mendoza. |
| |
//| https://www.mql5.com/ |
| |
//+------------------------------------------------------------------+
| |
#property copyright "Copyright 2026, Niquel Mendoza."
| |
#property link "https://www.mql5.com/"
| |
#property version "1.00"
| |
#property strict
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
#include "Loader.mqh"
| |
#include "..\\Dict\\DictT.mqh"
| |
| |
//+------------------------------------------------------------------+
| |
//| Script program start function |
| |
//+------------------------------------------------------------------+
| |
void OnStart()
| |
{
| |
//---
| |
const string values[3]
| |
{
| |
"PERIOD_M10",
| |
"PERIOD_M5",
| |
"PERIOD_MN1"
| |
};
| |
| |
| |
ulong a = GetMicrosecondCount();
| |
for(int i = 0; i < 10000; i++)
| |
{
| |
const int r = MathRand() % 3;
| |
TSN::CEnumRegBasis::GetVal<ENUM_TIMEFRAMES>(values[r], PERIOD_CURRENT);
| |
}
| |
ulong b = GetMicrosecondCount() - a;
| |
Print("Time PH: ", b);
| |
| |
| |
CDictSValue<int> dict;
| |
dict.Add("PERIOD_M1", PERIOD_M1);
| |
dict.Add("PERIOD_M2", PERIOD_M2);
| |
dict.Add("PERIOD_M3", PERIOD_M3);
| |
dict.Add("PERIOD_M4", PERIOD_M4);
| |
dict.Add("PERIOD_M5", PERIOD_M5);
| |
dict.Add("PERIOD_M10", PERIOD_M10);
| |
dict.Add("PERIOD_M6", PERIOD_M6);
| |
dict.Add("PERIOD_MN1", PERIOD_MN1);
| |
int sd;
| |
| |
a = GetMicrosecondCount();
| |
for(int i = 0; i < 10000; i++)
| |
{
| |
const int r = MathRand() % 3;
| |
dict.TryGet(values[r], sd);
| |
}
| |
b = GetMicrosecondCount() - a;
| |
Print("Time Dict: ", b);
| |
| |
// Fast...
| |
/*
| |
2026.06.30 11:34:22.050 Test (EURUSD,M5) Time Dict: 503
| |
2026.06.30 11:34:22.390 Test (EURUSD,M5) Time PH: 281
| |
2026.06.30 11:34:22.391 Test (EURUSD,M5) Time Dict: 512
| |
2026.06.30 11:34:22.745 Test (EURUSD,M5) Time PH: 282
| |
2026.06.30 11:34:22.746 Test (EURUSD,M5) Time Dict: 528
| |
*/
| |
}
| |
//+------------------------------------------------------------------+
|