CryptoByLeo/Src/Hash/Test/TestB2.mq5
Nique_372 ca93000d9d
2026-08-11 21:00:11 -05:00

54 lines
1.7 KiB
MQL5

//+------------------------------------------------------------------+
//| TestB2.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 "..\\Blake2b.mqh"
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
int DataSizeMB = 32;
int dataSize = DataSizeMB * 1024 * 1024;
uchar data[];
ArrayResize(data, dataSize);
MathSrand(42);
for(int i = 0; i < dataSize; i++)
data[i] = (uchar)(MathRand() % 256);
uchar fin[64];
ulong a = GetMicrosecondCount();
TSN::CCryptoHash::BLAKE2B(data, dataSize, fin, 64);
ulong b = GetMicrosecondCount();
double shaSeconds = (b - a) / 1000000.0;
double shaMBs = DataSizeMB / shaSeconds;
PrintFormat(" Tiempo: %.4f s", shaSeconds);
PrintFormat(" Velocidad: %.2f MB/s", shaMBs);
uchar r = 0;
for(int i = 0; i < 64; i++)
r += fin[i];
Print(r);
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+