2026-08-11 10:06:33 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| 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()
|
| | | {
|
2026-08-12 19:41:32 -05:00 | | | int MB = 1;
|
2026-08-14 13:12:06 -05:00 | | | int REPS = 50;
|
| | | double totalMB = MB * REPS;
|
2026-08-11 10:06:33 -05:00 | | |
|
2026-08-12 19:41:32 -05:00 | | | int n = MB * 1024 * 1024;
|
2026-08-11 10:06:33 -05:00 | | | 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();
|
2026-08-14 13:12:06 -05:00 | | | for(int i = 0; i < REPS; i++)
|
2026-08-12 18:18:45 -05:00 | | | {
|
2026-08-20 17:10:56 -05:00 | | | TSN::CCryptoHash::SHA256(data, n, fin, 0);
|
2026-08-12 18:18:45 -05:00 | | | }
|
2026-08-11 10:06:33 -05:00 | | | ulong b = GetMicrosecondCount();
|
| | | double t1 = (b - a) / 1000000.0;
|
2026-08-14 13:12:06 -05:00 | | | Print("MQL5 SHA256: ", t1, " s ", (totalMB / t1), " MB/s", " dumm: " , fin[0]);
|
2026-08-11 10:06:33 -05:00 | | |
|
| | | a = GetMicrosecondCount();
|
2026-08-14 13:12:06 -05:00 | | | for(int i = 0; i < REPS; i++)
|
2026-08-12 18:18:45 -05:00 | | | {
|
| | | CryptEncode(CRYPT_HASH_SHA256, data, key, fin);
|
| | | }
|
2026-08-11 10:06:33 -05:00 | | | b = GetMicrosecondCount();
|
| | | double t2 = (b - a) / 1000000.0;
|
2026-08-14 13:12:06 -05:00 | | | Print("CryptEncode: ", t2, " s ", (totalMB / t2), " MB/s", " dumm: " , fin[0]);
|
2026-08-11 10:06:33 -05:00 | | |
|
| | | Print("ratio: ", (t1 > t2 ? t1 / t2 : t2 / t1), (t1 > t2 ? " CryptEncode gana" : " MQL5 gana"));
|
| | | }
|
2026-08-14 13:12:06 -05:00 | | | //+------------------------------------------------------------------+
|