53 lines
1.9 KiB
MQL5
53 lines
1.9 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| Tesrt.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 "..\\SHA256.mqh"
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| Script program start function |
|
|
//+------------------------------------------------------------------+
|
|
void OnStart()
|
|
{
|
|
int MB = 1;
|
|
|
|
int n = MB * 1024 * 1024;
|
|
uchar data[];
|
|
ArrayResize(data, n);
|
|
MathSrand(42);
|
|
for(int i = 0; i < n; i++)
|
|
data[i] = (uchar)(MathRand() % 256);
|
|
|
|
uchar fin[CRYPTOBYLEO_SHA256_SIZET_FHASH];
|
|
uchar key[];
|
|
|
|
ulong a = GetMicrosecondCount();
|
|
for(int i = 0; i < 50; i++)
|
|
{
|
|
TSN::CCryptoHash::SHA256(data, n, fin);
|
|
}
|
|
ulong b = GetMicrosecondCount();
|
|
double t1 = (b - a) / 1000000.0;
|
|
Print("MQL5 SHA256: ", t1, " s ", (MB / t1), " MB/s", " dumm: " , fin[0]);
|
|
|
|
a = GetMicrosecondCount();
|
|
for(int i = 0; i < 50; i++)
|
|
{
|
|
CryptEncode(CRYPT_HASH_SHA256, data, key, fin);
|
|
}
|
|
b = GetMicrosecondCount();
|
|
double t2 = (b - a) / 1000000.0;
|
|
Print("CryptEncode: ", t2, " s ", (MB / t2), " MB/s", " dumm: " , fin[0]);
|
|
|
|
Print("ratio: ", (t1 > t2 ? t1 / t2 : t2 / t1), (t1 > t2 ? " CryptEncode gana" : " MQL5 gana"));
|
|
}
|
|
//+------------------------------------------------------------------+
|