Skip to content

Performance Ilist Sorting Performance

github-actions[bot] edited this page May 8, 2026 · 9 revisions

IList Sorting Performance Benchmarks

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 Cheatsheet

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.

Dataset Scenarios

  • 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.

Windows (Editor/Player)

Last updated 2026-05-08 04:05 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.

Sorted

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.002 ms 0.001 ms 0.001 ms 0.093 ms 0.001 ms 0.006 ms 0.001 ms 0.002 ms 0.001 ms 0.001 ms 0.001 ms 0.002 ms 0.002 ms
1,000 0.026 ms 0.031 ms 0.009 ms 0.007 ms 0.006 ms 0.007 ms 0.006 ms 1.16 ms 0.007 ms 0.110 ms 0.009 ms 0.019 ms 0.006 ms 0.038 ms 0.006 ms 0.006 ms 0.032 ms
10,000 0.324 ms 0.443 ms 0.090 ms 0.071 ms 0.055 ms 0.069 ms 0.053 ms 14.4 ms 0.071 ms 1.56 ms 0.091 ms 0.190 ms 0.059 ms 0.616 ms 0.055 ms 0.054 ms 0.434 ms
100,000 3.93 ms 5.78 ms 0.894 ms 0.703 ms 0.542 ms n/a 0.527 ms 181 ms 0.702 ms 20.2 ms 0.897 ms 1.91 ms 0.597 ms 7.46 ms 0.545 ms 0.530 ms 5.50 ms

Nearly Sorted (2% swaps)

List Size Ghost Meteor Pattern-Defeating QuickSort Grail Power Insertion Tim Jesse Green Ska Ipn Smooth Block IPS4o Power+ Glide Flux
100 0.002 ms 0.002 ms 0.002 ms 0.001 ms 0.002 ms 0.001 ms 0.002 ms 0.099 ms 0.001 ms 0.006 ms 0.002 ms 0.002 ms 0.001 ms 0.002 ms 0.002 ms 0.002 ms 0.002 ms
1,000 0.026 ms 0.031 ms 0.037 ms 0.009 ms 0.019 ms 0.008 ms 0.015 ms 1.20 ms 0.007 ms 0.110 ms 0.034 ms 0.019 ms 0.008 ms 0.047 ms 0.025 ms 0.016 ms 0.034 ms
10,000 0.326 ms 0.444 ms 0.508 ms 0.081 ms 0.258 ms 0.071 ms 0.192 ms 14.1 ms 0.078 ms 1.57 ms 0.466 ms 0.198 ms 0.079 ms 0.721 ms 0.403 ms 0.181 ms 0.440 ms
100,000 3.99 ms 5.88 ms 6.07 ms 0.820 ms 4.06 ms n/a 2.75 ms 189 ms 0.802 ms 20.3 ms 5.74 ms 1.96 ms 0.720 ms 8.66 ms 5.75 ms 2.43 ms 5.58 ms

Shuffled (deterministic)

List Size Ghost Meteor Pattern-Defeating QuickSort Grail Power Insertion Tim Jesse Green Ska Ipn Smooth Block IPS4o Power+ Glide Flux
100 0.010 ms 0.008 ms 0.006 ms 0.007 ms 0.008 ms 0.018 ms 0.011 ms 0.041 ms 0.008 ms 0.009 ms 0.008 ms 0.011 ms 0.005 ms 0.006 ms 0.023 ms 0.012 ms 0.008 ms
1,000 0.167 ms 0.137 ms 0.096 ms 0.107 ms 0.111 ms 1.67 ms 0.159 ms 0.442 ms 0.117 ms 0.139 ms 0.104 ms 0.200 ms 0.092 ms 0.109 ms 0.432 ms 0.172 ms 0.105 ms
10,000 2.32 ms 2.00 ms 1.30 ms 1.48 ms 1.55 ms 166 ms 1.67 ms 5.46 ms 1.46 ms 1.90 ms 1.39 ms 2.89 ms 1.27 ms 1.63 ms 5.95 ms 1.94 ms 1.49 ms
100,000 33.6 ms 26.4 ms 16.2 ms 18.8 ms 18.9 ms n/a 21.8 ms 68.2 ms 18.9 ms 24.0 ms 17.0 ms 36.9 ms 15.8 ms 20.1 ms 79.3 ms 26.2 ms 18.8 ms

macOS

Pending — run the IList sorting benchmark suite on macOS to capture results.

Linux

Pending — run the IList sorting benchmark suite on Linux to capture results.

Other Platforms

Pending — run the IList sorting benchmark suite on the target platform to capture results.

Clone this wiki locally