CBitBuffer/TicksShort_VLQ/TicksShort_Performance.mq5

58 lines
4.7 KiB
MQL5
Raw Permalink Normal View History

2025-10-07 00:22:12 +03:00
<EFBFBD><EFBFBD>#property script_show_inputs
input datetime inFrom = D'2024.12.01';
2025-10-08 02:04:24 +03:00
//#include "TicksShort.mqh" // >@>B:89 D>@<0B E@0=5=8O B8:>2.
2025-10-08 07:25:58 +03:00
#include "TicksShortLite.mqh"
2025-10-07 00:22:12 +03:00
// >72@0I05B @07<5@ <0AA820 2 109B0E.
template <typename T>
ulong GetSize( const T &Array[] ) { return((ulong)sizeof(T) * ArraySize(Array)); }
template <typename T1, typename T2>
double Criterion( const T1 &Decompression[], const T2 &Compression[], const ulong Interval )
{
const double Performance = (double)ArraySize(Decompression) / Interval;
return(Performance * ((double)GetSize(Decompression) / GetSize(Compression)));
}
void OnStart()
{
MqlTick Ticks[]; // ;O 8AE>4=KE B8:>2.
if (CopyTicksRange(_Symbol, Ticks, COPY_TICKS_ALL,(ulong)inFrom * 1000) > 0)
{
//TICK_SHORT Ticks2[]; // ;O A60BKE B8:>2.
2025-10-08 02:04:24 +03:00
uchar Ticks2[];
2025-10-07 00:22:12 +03:00
ulong Interval = GetMicrosecondCount();
TICKS_SHORT::Compress(Ticks, Ticks2); // !60;8.
Interval = GetMicrosecondCount() - Interval;
const double Performance = (double)ArraySize(Ticks) / Interval;
// https://www.mql5.com/ru/forum/490384#comment_57497700
long n1 = ArraySize(Ticks) * (long)sizeof(MqlTick);
//long n2 = ArraySize(Ticks2) * (long)sizeof(TICK_SHORT);
2025-10-08 02:04:24 +03:00
long n2 = ArraySize(Ticks2) * (long)sizeof(uchar);
2025-10-07 00:22:12 +03:00
PrintFormat("Compressed %I64i bytes into %I64i bytes ==> %.2f%%",n1,n2,(double)n2/n1*100);
Print("Compress performance: " + DoubleToString(Performance * sizeof(MqlTick) / 1.04858, 0) + " MB/s");
Print("Compress performance: " + DoubleToString(Performance, 1) + " Ticks (millions)/sec.");
Print("Compress performance criterion: " + DoubleToString(Criterion(Ticks, Ticks2, Interval), 1));
MqlTick Ticks3[]; // ;O @0760BKE B8:>2.
ulong Interval2 = GetMicrosecondCount();
TICKS_SHORT::Decompress(Ticks2, Ticks3); // 0760;8.
Interval2 = GetMicrosecondCount() - Interval2;
const double Performance2 = (double)ArraySize(Ticks3) / Interval2;
Print("Decompress performance: " + DoubleToString(Performance2 * sizeof(MqlTick) / 1.04858, 0) + " MB/s");
Print("Decompress performance: " + DoubleToString(Performance2, 1) + " Ticks (millions)/sec.");
Print("Decompress performance criterion: " + DoubleToString(Criterion(Ticks3, Ticks2, Interval2), 1));
Print("Correct = " + (string)TICKS_SHORT::IsEqual(Ticks, Ticks3)); // !@02=8;8.
}
}