MQLArticles/Utils/Sort/Test/Test.mq5
2026-09-15 15:46:48 -05:00

49 lines
1.7 KiB
MQL5

//+------------------------------------------------------------------+
//| Test.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 "..\\Generic\\Simple.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#define SIZE 10*1000*1000
int arr1[SIZE];
int arr2[SIZE];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnStart()
{
//---
for(int i = 0; i < SIZE; i++)
{
arr1[i] = MathRand();
arr2[i] = arr1[i];
}
//---
ulong t1 = GetMicrosecondCount();
ArraySort(arr1);
ulong ticks1 = GetMicrosecondCount() - t1;
Print("native: ", ticks1);
//---
ulong t2 = GetMicrosecondCount();
TsnSort(arr2, 0, SIZE - 1, int);
ulong ticks2 = GetMicrosecondCount() - t2;
Print("isort: ", ticks2);
}
//+------------------------------------------------------------------+