-
Notifications
You must be signed in to change notification settings - Fork 12
Performance Ilist Sorting Performance
Unity Helpers ships several custom sorting algorithms for IList<T> that cover different trade-offs between adaptability, allocation patterns, and stability. This page gathers context and benchmark snapshots so you can choose the right algorithm for your workload and compare results across operating systems.
| Algorithm | Stable? | Best For | Reference |
|---|---|---|---|
| Ghost Sort | No | Mixed workloads that benefit from adaptive gap sorting and few allocations | Upstream project by Will Stafford Parsons (public repository currently offline) |
| Meteor Sort | No | Almost-sorted data where gap shrinking beats plain insertion sort | Upstream project by Will Stafford Parsons (public repository currently offline) |
| Pattern-Defeating QuickSort | No | General-purpose quicksort with protections against worst-case inputs | pdqsort by Orson Peters |
| Grail Sort | Yes | Large datasets where stability + low allocations matter | GrailSort |
| Power Sort | Yes | Partially ordered data that benefits from adaptive run detection | PowerSort (Munro & Wild) |
| Tim Sort | Yes | General-purpose stable sorting with abundant natural runs | Wikipedia - Timsort |
| Jesse Sort | No | Data with long runs or duplicates where dual patience piles shine | JesseSort |
| Green Sort | Yes | Sustainable stable merges that trim ordered prefixes | greeNsort |
| Ska Sort | No | Branch-friendly partitioning on large unstable datasets | Ska Sort |
| Ipn Sort | No | In-place adaptive quicksort scenarios needing robust pivots | ipnsort write-up |
| Smooth Sort | No | Weak-heap hybrid that approaches O(n) for presorted data | Smoothsort - Wikipedia |
| Block Merge Sort | Yes | Stable merges with √n buffer (WikiSort style) | WikiSort |
| IPS⁴o Sort | No | Cache-aware samplesort with multiway partitioning | IPS⁴o paper |
| Power Sort Plus | Yes | Enhanced run-priority merges inspired by Wild & Nebel | PowerSort paper |
| Glide Sort | Yes | Stable galloping merges from the Rust glidesort research | sort-research-rs |
| Flux Sort | No | Dual-pivot quicksort tuned for modern CPUs | sort-research-rs |
| Insertion Sort | Yes | Tiny or nearly sorted collections where O(n²) is acceptable | Wikipedia - Insertion sort |
What does “stable” mean? Stable sorting algorithms preserve the relative order of elements that compare as equal. This matters when items carry secondary keys (e.g., sorting people by last name but keeping first-name order deterministic). Unstable algorithms can reshuffle equal entries, which is usually fine for numeric keys but can break deterministic pipelines.
Heads up: The original Ghost Sort repository was formerly hosted on GitHub under
wstaffordp/ghostsort, but it currently returns 404. The Unity Helpers implementation remains based on that source; we will relink if/when an official mirror returns.
- Sorted – ascending integers, verifying best-case behavior.
- Nearly Sorted (2% swaps) – deterministic neighbor swaps introduce light disorder to expose adaptive optimizations.
- Shuffled (deterministic) – Fisher–Yates shuffle using a fixed seed for reproducibility across runs and machines.
Each benchmark sorts a fresh copy of the dataset once and reports wall-clock duration. If a cell still shows pending, re-run the benchmark suite to collect fresh data for that algorithm/dataset size.
Run the IListSortingPerformanceTests.Benchmark test inside Unity’s Test Runner to refresh the tables below. Results automatically land in the section that matches the current operating system.
Last updated 2026-04-21 03:15 UTC on Windows 11 (10.0.26200) 64bit
Times are single-pass measurements in milliseconds (lower is better). n/a indicates the algorithm was skipped for the dataset size.
| List Size | Ghost | Meteor | Pattern-Defeating QuickSort | Grail | Power | Insertion | Tim | Jesse | Green | Ska | Ipn | Smooth | Block | IPS4o | Power+ | Glide | Flux |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 100 | 0.005 ms | 0.002 ms | 0.001 ms | 0.001 ms | 0.001 ms | 0.001 ms | 0.001 ms | 0.098 ms | 0.001 ms | 0.006 ms | 0.001 ms | 0.002 ms | 0.001 ms | 0.001 ms | 0.001 ms | 0.001 ms | 0.002 ms |
| 1,000 | 0.022 ms | 0.026 ms | 0.007 ms | 0.007 ms | 0.005 ms | 0.006 ms | 0.005 ms | 1.23 ms | 0.006 ms | 0.098 ms | 0.007 ms | 0.017 ms | 0.005 ms | 0.036 ms | 0.005 ms | 0.005 ms | 0.028 ms |
| 10,000 | 0.276 ms | 0.376 ms | 0.071 ms | 0.062 ms | 0.044 ms | 0.056 ms | 0.042 ms | 14.6 ms | 0.062 ms | 1.46 ms | 0.072 ms | 0.168 ms | 0.048 ms | 0.585 ms | 0.044 ms | 0.044 ms | 0.404 ms |
| 100,000 | 3.36 ms | 4.94 ms | 0.717 ms | 0.621 ms | 0.430 ms | n/a | 0.415 ms | 186 ms | 0.609 ms | 18.1 ms | 0.745 ms | 1.67 ms | 0.490 ms | 7.01 ms | 0.429 ms | 0.422 ms | 4.75 ms |
| List Size | Ghost | Meteor | Pattern-Defeating QuickSort | Grail | Power | Insertion | Tim | Jesse | Green | Ska | Ipn | Smooth | Block | IPS4o | Power+ | Glide | Flux |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 100 | 0.001 ms | 0.002 ms | 0.002 ms | 0.001 ms | 0.002 ms | 0.001 ms | 0.001 ms | 0.093 ms | 0.001 ms | 0.006 ms | 0.002 ms | 0.002 ms | 0.001 ms | 0.002 ms | 0.003 ms | 0.002 ms | 0.002 ms |
| 1,000 | 0.022 ms | 0.026 ms | 0.031 ms | 0.007 ms | 0.016 ms | 0.006 ms | 0.014 ms | 1.21 ms | 0.007 ms | 0.098 ms | 0.027 ms | 0.017 ms | 0.006 ms | 0.043 ms | 0.023 ms | 0.015 ms | 0.029 ms |
| 10,000 | 0.277 ms | 0.375 ms | 0.409 ms | 0.071 ms | 0.226 ms | 0.064 ms | 0.167 ms | 14.2 ms | 0.068 ms | 1.41 ms | 0.386 ms | 0.174 ms | 0.069 ms | 0.646 ms | 0.370 ms | 0.160 ms | 0.380 ms |
| 100,000 | 3.33 ms | 4.90 ms | 4.95 ms | 0.710 ms | 3.58 ms | n/a | 2.38 ms | 173 ms | 0.695 ms | 18.1 ms | 4.63 ms | 1.72 ms | 0.603 ms | 7.97 ms | 5.34 ms | 2.24 ms | 4.84 ms |
| List Size | Ghost | Meteor | Pattern-Defeating QuickSort | Grail | Power | Insertion | Tim | Jesse | Green | Ska | Ipn | Smooth | Block | IPS4o | Power+ | Glide | Flux |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 100 | 0.008 ms | 0.007 ms | 0.005 ms | 0.006 ms | 0.007 ms | 0.016 ms | 0.010 ms | 0.041 ms | 0.007 ms | 0.008 ms | 0.007 ms | 0.010 ms | 0.005 ms | 0.005 ms | 0.023 ms | 0.011 ms | 0.006 ms |
| 1,000 | 0.146 ms | 0.126 ms | 0.093 ms | 0.102 ms | 0.108 ms | 1.38 ms | 0.139 ms | 0.439 ms | 0.106 ms | 0.130 ms | 0.094 ms | 0.186 ms | 0.086 ms | 0.106 ms | 0.422 ms | 0.150 ms | 0.098 ms |
| 10,000 | 2.04 ms | 1.83 ms | 1.19 ms | 1.39 ms | 1.46 ms | 137 ms | 1.54 ms | 5.42 ms | 1.35 ms | 1.77 ms | 1.28 ms | 2.63 ms | 1.17 ms | 1.52 ms | 5.89 ms | 1.72 ms | 1.41 ms |
| 100,000 | 29.4 ms | 24.5 ms | 15.0 ms | 17.6 ms | 18.0 ms | n/a | 19.8 ms | 68.4 ms | 17.5 ms | 22.5 ms | 15.6 ms | 33.6 ms | 14.7 ms | 20.0 ms | 74.4 ms | 22.6 ms | 17.5 ms |
Pending — run the IList sorting benchmark suite on macOS to capture results.
Pending — run the IList sorting benchmark suite on Linux to capture results.
Pending — run the IList sorting benchmark suite on the target platform to capture results.
📦 Unity Helpers | 📖 Documentation | 🐛 Issues | 📜 MIT License
- Inspector Button
- Inspector Conditional Display
- Inspector Grouping Attributes
- Inspector Inline Editor
- Inspector Overview
- Inspector Selection Attributes
- Inspector Settings
- Inspector Validation Attributes
- Utility Components
- Visual Components
- Data Structures
- Helper Utilities
- Math And Extensions
- Pooling Guide
- Random Generators
- Reflection Helpers
- Singletons