JsonParserByLeo/Test/Ben.mq5

60 lines
1.9 KiB
MQL5

2026-06-03 08:32:38 -05:00
//+------------------------------------------------------------------+
//| Ben.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
2026-06-03 08:45:12 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "..\\..\\fast_json\\fast_json.mqh"
2026-06-03 08:32:38 -05:00
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "..\\Src\\JsonNode.mqh"
2026-06-03 08:45:12 -05:00
#resource "twitter.json" as const string g_json_data
2026-06-03 08:32:38 -05:00
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
TSN::CJsonParser parser;
2026-06-03 08:51:42 -05:00
// Only one copy
2026-06-03 08:45:12 -05:00
parser.Assing(g_json_data);
2026-06-03 08:32:38 -05:00
uint a = GetTickCount();
for(int i = 0; i < 1000; i++)
{
parser.Parse();
}
uint b = GetTickCount() - a;
Print("Time: ", b);
//---
2026-06-03 08:45:12 -05:00
CJson json;
2026-06-03 08:51:42 -05:00
// Only one copy
StringToCharArray(g_json_data, json.ctx.buffer);
2026-06-03 08:45:12 -05:00
a = GetTickCount();
for(int i = 0; i < 1000; i++)
{
2026-06-03 08:51:42 -05:00
json.ParseData();
2026-06-03 08:45:12 -05:00
}
b = GetTickCount() - a;
Print("Time: ", b);
2026-06-03 08:51:42 -05:00
//---
/*
2026.06.03 08:51:12.467 Ben (EURUSD,M1) Time: 1094
2026.06.03 08:51:13.736 Ben (EURUSD,M1) Time: 1265
*/
2026-06-03 08:32:38 -05:00
}
//+------------------------------------------------------------------+