138 lines
5.2 KiB
MQL5
138 lines
5.2 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| UtilFinish.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 MQLARTICLES_MBEN_ENABLE_FINAL_FLUSH
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
#include "Def.mqh"
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
#ifndef FINISH_BENCH_LOGFILE
|
|
//+------------------------------------------------------------------+
|
|
//| Datos recolectados del log 20260828.log (parse|twitter.json) |
|
|
//+------------------------------------------------------------------+
|
|
struct SBenchResult
|
|
{
|
|
string tag;
|
|
string dataset;
|
|
string lib_name;
|
|
int iter;
|
|
long total;
|
|
};
|
|
|
|
SBenchResult s_bench_data[] =
|
|
{
|
|
{"parse", "twitter.json", "JsonParserByLeo-DLL", 1000, 356472},
|
|
{"parse", "twitter.json", "YamlParserByLeo", 1000, 899923},
|
|
{"parse", "twitter.json", "JsonParserByLeo", 1000, 647487},
|
|
{"parse", "twitter.json", "FastJson", 1000, 1213429},
|
|
{"parse", "twitter.json", "JAson", 1000, 21118681},
|
|
{"parse", "twitter.json", "MQL5-JsonLib", 1000, 17547384},
|
|
{"parse", "twitter.json", "JsonParserByLeo-ASM", 1000, 637971},
|
|
{"parse", "twitter.json", "ClaudeFableJson-OnePass", 1000, 1060569},
|
|
{"parse", "twitter.json", "ClaudeFableJson-3+Pass", 1000, 1063043},
|
|
{"parse", "twitter.json", "GLM", 1000, 1249760},
|
|
{"parse", "twitter.json", "ToyJson3", 1000, 4859},
|
|
{"parse", "twitter.json", "CJsonNode_MQL5Articles", 1000, 86409036} // agregado manualmente: ciclo sin cierre "%" en el log, unico valor @ capturado
|
|
};
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Guarda los resultados de s_bench_data en la base de datos comun |
|
|
//+------------------------------------------------------------------+
|
|
void SaveBenchResultsToDB(const string name)
|
|
{
|
|
const int sql_handle = DatabaseOpen(name, DATABASE_OPEN_COMMON | DATABASE_OPEN_CREATE | DATABASE_OPEN_READWRITE);
|
|
if(sql_handle == INVALID_HANDLE)
|
|
{
|
|
FastLog(FUNCION_ACTUAL, FATAL_ERROR_TEXT, StringFormat("Fallo al abrir la db [%s], last err = %d",
|
|
name, ::GetLastError()));
|
|
return;
|
|
}
|
|
|
|
//--- creamos si no existe
|
|
if(!DatabaseExecute(sql_handle, g_mqlarticles_mben_sql_init))
|
|
{
|
|
DatabaseClose(sql_handle);
|
|
FastLog(FUNCION_ACTUAL, FATAL_ERROR_TEXT, StringFormat("Fallo al crear la tabla db, last err = %d", ::GetLastError()));
|
|
return;
|
|
}
|
|
|
|
//--- Iniciamos
|
|
::ResetLastError();
|
|
if(!DatabaseTransactionBegin(sql_handle))
|
|
{
|
|
DatabaseClose(sql_handle);
|
|
FastLog(FUNCION_ACTUAL, FATAL_ERROR_TEXT, StringFormat("Fallo al inicar transacion datos al m_sql_handle: ", ::GetLastError()));
|
|
return;
|
|
}
|
|
|
|
//---
|
|
::ResetLastError();
|
|
const int stmt = DatabasePrepare(sql_handle, g_mqlarticles_mben_sql_insert);
|
|
if(stmt == INVALID_HANDLE)
|
|
{
|
|
DatabaseClose(sql_handle);
|
|
FastLog(FUNCION_ACTUAL, FATAL_ERROR_TEXT, StringFormat("Fallo al ejeuctar un preprare de la base de datos, ultimo err = %d",
|
|
::GetLastError()));
|
|
return;
|
|
}
|
|
|
|
//---
|
|
const string run_date = TimeToString(TimeLocal(), TIME_DATE);
|
|
const int total = ArraySize(s_bench_data);
|
|
for(int i = 0; i < total; i++)
|
|
{
|
|
DatabaseReset(stmt);
|
|
DatabaseBind(stmt, 0, run_date);
|
|
DatabaseBind(stmt, 1, s_bench_data[i].tag);
|
|
DatabaseBind(stmt, 2, s_bench_data[i].dataset);
|
|
DatabaseBind(stmt, 3, s_bench_data[i].lib_name);
|
|
DatabaseBind(stmt, 4, s_bench_data[i].iter);
|
|
DatabaseBind(stmt, 5, s_bench_data[i].total);
|
|
DatabaseRead(stmt);
|
|
}
|
|
|
|
//---
|
|
DatabaseFinalize(stmt);
|
|
|
|
//---
|
|
::ResetLastError();
|
|
if(!DatabaseTransactionCommit(sql_handle))
|
|
{
|
|
DatabaseClose(sql_handle);
|
|
FastLog(FUNCION_ACTUAL, FATAL_ERROR_TEXT, StringFormat("Fallo al enviar datos al m_sql_handle: ", ::GetLastError()));
|
|
return;
|
|
}
|
|
|
|
//---
|
|
DatabaseClose(sql_handle);
|
|
}
|
|
#endif
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Script program start function |
|
|
//+------------------------------------------------------------------+
|
|
void OnStart()
|
|
{
|
|
#ifdef FINISH_BENCH_LOGFILE
|
|
TSN::CMultiBenchmark::ParseLogFileTodayFlushDb(JSONBENCH_DB_NAME);
|
|
#else
|
|
SaveBenchResultsToDB(JSONBENCH_DB_NAME);
|
|
#endif // FINISH_BENCH_LOGFILE
|
|
}
|
|
//+------------------------------------------------------------------+
|