CryptoByLeo/Src/Hash/Test/Test512.mq5
Nique_372 17ce61d3e3
2026-08-26 22:23:21 -05:00

65 lines
1.9 KiB
MQL5

//+------------------------------------------------------------------+
//| Test512.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 "..\\SHA512.mqh"
#include <TSN\\BInt\\NUtils.mqh>
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
uchar fin[CRYPTOBYLEO_SHA512_SIZET_FHASH];
//---
/* uchar data[];
ArrayResize(data, 128);
ArrayInitialize(data, 'A');
TSN::CCryptoHash::SHA512(data, 128, fin);
string out = "";
TSN::CNumberUtils::BytesToHexUpper(fin, CRYPTOBYLEO_SHA512_SIZET_FHASH, out);
Print(out);*/
//---
int DataSizeMB = 1;
int dataSize = DataSizeMB * 1024 * 1024;
uchar data[];
ArrayResize(data, dataSize);
MathSrand(42);
for(int i = 0; i < dataSize; i++)
data[i] = (uchar)(MathRand() % 256);
ulong a = GetMicrosecondCount();
TSN::CCryptoHash::SHA512(data, dataSize, fin, 0);
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);
}
//+------------------------------------------------------------------+