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

65 行
2.3 KiB
MQL5

//+------------------------------------------------------------------+
//| Claude.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 "..\\Other\\ClaudeJson.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.Root();
string keys[];
CJsonNode valores = root["valores"];
const int n = valores.Count();
ArrayResize(keys, n);
for(int i = 0; i < n; i++)
{
keys[i] = parser.KeyAt(parser.FindChildIndex(valores.Index(), i));
}
//ArrayPrint(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:42:58.187 Claude (EURUSD,H1) First prueba: 600
2026.06.28 18:42:59.693 Claude (EURUSD,H1) First prueba: 595
2026.06.28 18:43:00.576 Claude (EURUSD,H1) First prueba: 605
2026.06.28 18:43:01.305 Claude (EURUSD,H1) First prueba: 605
2026.06.28 18:43:02.018 Claude (EURUSD,H1) First prueba: 601
*/
}
//+------------------------------------------------------------------+