JsonParserByLeo/Test/All/FastJson.mq5
2026-06-28 18:47:50 -05:00

58 lines
2.1 KiB
MQL5

//+------------------------------------------------------------------+
//| FastJson.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 "..\\..\\..\\fast_json\\fast_json.mqh"
#include "..\\..\\..\\Xoshiro256\\Xoshiro256.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#resource "test.json" as const string g_json_test
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
//---
CJson parser;
parser.Parse(g_json_test);
CJsonNode root = parser.GetRoot();
string keys[];
const int n = root["valores"].GetKeys(keys);
Xoshiro256 xo;
xo.Seed(156015641);
//--- Prueba 1 acceso a valor..
ulong a = GetMicrosecondCount();
for(int i = 0; i < 1000; i++)
{
const string key = keys[xo.RandomInteger(0, n)];
root["valores"][key];
}
ulong b = GetMicrosecondCount() - a;
Print("First prueba: ", b);
/*
2026.06.28 18:33:26.763 FastJson (EURUSD,H1) First prueba: 223
2026.06.28 18:33:27.903 FastJson (EURUSD,H1) First prueba: 223
2026.06.28 18:33:28.583 FastJson (EURUSD,H1) First prueba: 223
2026.06.28 18:33:29.004 FastJson (EURUSD,H1) First prueba: 223
*/
}
//+------------------------------------------------------------------+