58 lines
1.9 KiB
MQL5
//+------------------------------------------------------------------+
| |||
//| Test2.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 "Base64.mqh"
| |||
| |||
//+------------------------------------------------------------------+
| |||
//| Script program start function |
| |||
//+------------------------------------------------------------------+
| |||
void OnStart()
| |||
{
| |||
const int size = 800 * 600 * 4;
| |||
const int outLen = ((size + 2) / 3) * 4;
| |||
| |||
uchar src[];
| |||
ArrayResize(src, size);
| |||
MathSrand(42);
| |||
for(int i = 0; i < size; i++)
| |||
src[i] = (uchar)MathRand();
| |||
| |||
uchar key[]; // vacío para CRYPT_BASE64
| |||
uchar out[];
| |||
uchar buf[];
| |||
ArrayResize(buf, outLen); // fuera del cronómetro
| |||
| |||
//--- nativo
| |||
for(int k = 0; k < 3; k++)
| |||
{
| |||
ulong t0 = GetMicrosecondCount();
| |||
| |||
CryptEncode(CRYPT_BASE64, src, key, out);
| |||
ArrayCopy(out, key);
| |||
Print("N ", k, ": ", GetMicrosecondCount() - t0);
| |||
}
| |||
| |||
//--- in-place
| |||
for(int k = 0; k < 3; k++)
| |||
{
| |||
ArrayCopy(buf, src, 0, 0, size); // restaurar entrada (fuera del cronómetro)
| |||
| |||
ulong t0 = GetMicrosecondCount();
| |||
TSN::CBase64::EncodeInPlace(buf, 0, size);
| |||
Print("T ", k, ": ", GetMicrosecondCount() - t0);
| |||
}
| |||
| |||
//--- verificación (buf tiene la última salida in-place)
| |||
Print("iguales: ", ArrayCompare(out, buf, 0, 0, outLen) == 0);
| |||
}
| |||
//+------------------------------------------------------------------+
|