A high-performance sorting algorithm leveraging NEON vectorization and Grand Central Dispatch to deliver unparalleled speed on Apple Silicon hardware.
Processes multiple elements simultaneously using 128-bit vector registers, maximizing throughput and minimizing cycle time per element on Apple Silicon processors.
Efficiently balances workloads across all available CPU cores, dynamically adjusting thread allocation based on current system load and data characteristics.
Selects optimal sorting strategies based on input characteristics, seamlessly switching between algorithms to maximize performance for any data pattern or distribution.
Benchmark results comparing vsort against standard algorithms across different array sizes
| Size | vsort (ms) | quicksort (ms) | mergesort (ms) | std::qsort (ms) |
|---|---|---|---|---|
| 10,000 | 0.33 (baseline) | 0.36 (1.09×) | 0.33 (1.00×) | 0.48 (1.46×) |
| 100,000 | 1.20 (baseline) | 4.14 (3.45×) | 3.62 (3.02×) | 5.23 (4.36×) |
| 1,000,000 | 10.09 (baseline) | 44.87 (4.45×) | 39.81 (3.95×) | 59.88 (5.94×) |
#include "vsort.h"
// Create and initialize an array
int array[] = {5, 2, 9, 1, 5, 6};
// Calculate the size of the array
int size = sizeof(array) / sizeof(array[0]);
// Sort the array using vsort
vsort(array, size);