//+------------------------------------------------------------------+ //| GLM.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 //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ //#define JSONBENCH_RUN_PARSE //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #include "..\\Other\\GLM.mqh" #include "Def.mqh" #define LIBNAME "GLM" //+------------------------------------------------------------------+ //| Helper: GLM.mqh no expone "primer hijo" de un objeto en su API | //| publica (GetNode(parent,int) solo resuelve arrays). Como el | //| dataset de test.json es fijo (wide_object con key_001..key_100), | //| generamos las keys directamente en vez de enumerarlas via API. | //+------------------------------------------------------------------+ int GetKeysGLM(const int n, string &keys[]) { ArrayResize(keys, n); for(int i = 0; i < n; i++) keys[i] = StringFormat("key_%03d", i + 1); return n; } //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- CJson json; #ifdef JSONBENCH_RUN_PARSE StringToCharArray(g_json_data, json.Buffer); //Sleep(1000); ulong a = GetMicrosecondCount(); for(int i = 0; i < 1000; i++) json.Parse(); ulong b = GetMicrosecondCount() ; Print("@", b - a); #else StringToCharArray(g_json_test_access, json.Buffer); json.Parse(); CJsonValue root = json.Root(); CJsonValue wide = root["wide_object"]; string keys[]; const int n = wide.Size(); GetKeysGLM(n, keys); //-- Random TSN::CRandom xo; xo.Seed(JSONBENCH_ACCESO_XHOR_SEED); // init double sump = 0.0, profit = 0.0; long tin = 0; //-- ulong a = GetMicrosecondCount(); for(int i = 0; i < JSONBENCH_TOTAL_ITER_ACCESO; i++) { const string key = keys[xo.RandomInteger(0, n)]; root["wide_object"][key]; } ulong b = GetMicrosecondCount(); Sleep(100); JSONBENCH_ACCES_CALL(JSONBENCH_TAGOP_ACCESO_WIDE) a = GetMicrosecondCount(); for(int i = 0; i < JSONBENCH_TOTAL_ITER_ACCESO; i++) { root["deep_object"]["l1"]["l2"]["l3"]["l4"]["l5"]["l6"]["l7"]["l8"]["l9"]["l10"]["target"].AsStr(); } b = GetMicrosecondCount(); Sleep(100); JSONBENCH_ACCES_CALL(JSONBENCH_TAGOP_ACCESO_DEEP) a = GetMicrosecondCount(); for(int i = 0; i < JSONBENCH_TOTAL_ITER_ACCESO; i++) { const int index = xo.RandomInteger(0, 10000); tin += root["large_array"][index].AsInt(); } b = GetMicrosecondCount(); Sleep(100); JSONBENCH_ACCES_CALL(JSONBENCH_TAGOP_ACCESO_LARGE_ARR) a = GetMicrosecondCount(); for(int k = 0; k < 500; k++) { sump += root["array_of_objects"][k]["price"].AsDbl(); profit += root["array_of_objects"][k]["profit"].AsDbl(); const int s = root["array_of_objects"][k]["tags"].Size(); tin += StringLen(root["array_of_objects"][k]["tags"][k % s].AsStr()); } b = GetMicrosecondCount(); Sleep(100); JSONBENCH_ACCES_CALL(JSONBENCH_TAGOP_ACCESO_MIX) //---- PrintFormat("sump=%.2f profit=%.2f tin=%d ", sump, profit, tin); //--- JSONBENCH_FINISH #endif // JSONBENCH_RUN_PARSE } //+------------------------------------------------------------------+ /* 2026.08.28 11:42:20.074 GLM (EURUSD,H1) @1253725 2026.08.28 11:42:25.485 GLM (EURUSD,H1) @1249760 2026.08.28 11:42:29.821 GLM (EURUSD,H1) @1279949 2026.08.28 11:42:38.462 GLM (EURUSD,H1) @1252397 2026.08.28 11:42:41.666 GLM (EURUSD,H1) @1260843 2026.08.28 11:42:44.350 GLM (EURUSD,H1) @1251354 2026.08.28 11:42:46.816 GLM (EURUSD,H1) @1259705 2026.10.03 15:25:15.064 GLM (EURUSD,H1) [acceso-wide] Time: 9284 2026.10.03 15:25:15.174 GLM (EURUSD,H1) [acceso-deep] Time: 2589 2026.10.03 15:25:15.302 GLM (EURUSD,H1) [acceso-array-large] Time: 15550 2026.10.03 15:25:15.413 GLM (EURUSD,H1) [acceso-mixed-trading] Time: 6909 2026.10.03 15:25:15.413 GLM (EURUSD,H1) sump=537.48 profit=-337.50 tin=4927909 2026.10.03 15:25:19.108 GLM (EURUSD,H1) [acceso-wide] Time: 8826 2026.10.03 15:25:19.220 GLM (EURUSD,H1) [acceso-deep] Time: 2522 2026.10.03 15:25:19.349 GLM (EURUSD,H1) [acceso-array-large] Time: 15674 2026.10.03 15:25:19.460 GLM (EURUSD,H1) [acceso-mixed-trading] Time: 5894 2026.10.03 15:25:19.460 GLM (EURUSD,H1) sump=537.48 profit=-337.50 tin=4927909 2026.10.03 15:25:22.402 GLM (EURUSD,H1) [acceso-wide] Time: 8898 2026.10.03 15:25:22.515 GLM (EURUSD,H1) [acceso-deep] Time: 2694 2026.10.03 15:25:22.643 GLM (EURUSD,H1) [acceso-array-large] Time: 15600 2026.10.03 15:25:22.769 GLM (EURUSD,H1) [acceso-mixed-trading] Time: 6901 2026.10.03 15:25:22.769 GLM (EURUSD,H1) sump=537.48 profit=-337.50 tin=4927909 */