diff --git a/benchmark_di/REPORT.md b/benchmark_di/REPORT.md index 2f80c40..9bd32bc 100644 --- a/benchmark_di/REPORT.md +++ b/benchmark_di/REPORT.md @@ -20,31 +20,47 @@ ## Comparative Table: chainCount=100, nestingDepth=100, repeat=5, warmup=2 (Mean time, µs) -| Scenario | cherrypick | get_it | riverpod | kiwi | -|------------------|------------|--------|----------|------| -| chainSingleton | 47.6 | 13.0 | 389.6 | 46.8 | -| chainFactory | 93.6 | 68.4 | 678.4 | 40.8 | -| register | 67.4 | 10.2 | 242.2 | 56.2 | -| named | 14.2 | 10.6 | 10.4 | 8.2 | -| override | 42.2 | 11.2 | 302.8 | 44.6 | -| chainAsync | 519.4 | 38.0 | 886.6 | – | +| Scenario | cherrypick | get_it | riverpod | kiwi | yx_scope | +|------------------|------------|--------|----------|-------|----------| +| chainSingleton | 20.6 | 14.8 | 275.2 | 47.0 | 82.8 | +| chainFactory | 90.6 | 71.6 | 357.0 | 46.2 | 79.6 | +| register | 82.6 | 10.2 | 252.6 | 43.6 | 224.0 | +| named | 18.4 | 9.4 | 12.2 | 10.2 | 10.8 | +| override | 170.6 | 11.2 | 301.4 | 51.4 | 146.4 | +| chainAsync | 493.8 | 34.0 | 5,039.0 | – | 87.2 | + + +## Peak Memory Usage (Peak RSS, Kb) + +| Scenario | cherrypick | get_it | riverpod | kiwi | yx_scope | +|------------------|------------|--------|----------|--------|----------| +| chainSingleton | 338,224 | 326,752| 301,856 | 195,520| 320,928 | +| chainFactory | 339,040 | 335,712| 304,832 | 319,952| 318,688 | +| register | 333,760 | 334,208| 300,368 | 327,968| 326,736 | +| named | 241,040 | 229,632| 280,144 | 271,872| 266,352 | +| override | 356,912 | 331,456| 329,808 | 369,104| 304,416 | +| chainAsync | 311,616 | 434,592| 301,168 | – | 328,912 | --- ## Analysis -- **get_it** and **kiwi** are the fastest in most sync scenarios; cherrypick is solid, riverpod is much slower for deep chains. -- **Async scenarios**: Only cherrypick, get_it and riverpod are supported; get_it is much faster. Kiwi does not support async. -- **Named** lookups are fast in all DI. -- **Riverpod** loses on deeply nested/async chains. -- **Memory/peak usage** varies, but mean_us is the main comparison (see raw results for memory). +- **get_it** remains the clear leader for both speed and memory usage (lowest latency across most scenarios; excellent memory efficiency even on deep chains). +- **kiwi** shows the lowest memory footprint in chainSingleton, but is unavailable for async chains. +- **yx_scope** demonstrates highly stable performance for both sync and async chains, often at the cost of higher memory usage, especially in the register/override scenarios. +- **cherrypick** comfortably beats riverpod, but is outperformed by get_it/kiwi/yx_scope, especially on async and heavy nested chains. It uses a bit less memory than yx_scope and kiwi, but can spike in memory/latency for override. +- **riverpod** is unsuitable for deep or async chains—latency and memory usage grow rapidly. +- **Peak memory (RSS):** usually around 320–340 MB for all DI; riverpod/kiwi occasionally drops below 300MB. named/factory scenarios use much less. +- **Stability:** yx_scope and get_it have the lowest latency spikes; cherrypick can show peaks on override/async; riverpod is least stable on async (stddev/mean much worse). ### Recommendations -- Use **get_it** or **kiwi** for maximum sync performance and simplicity. -- Use **cherrypick** for robust, scalable and testable setups — with a small latency cost. -- Use **riverpod** only for Flutter apps where integration is paramount and chains are simple. + +- **get_it** (and often **kiwi**, if you don't need async): best for ultra-fast deep graphs and minimum peak memory. +- **yx_scope**: best blend of performance and async stability; perfect for production mixed DI. +- **cherrypick**: great for modular/testable architectures, unless absolute peak is needed; lower memory than yx_scope in some scenarios. +- **riverpod**: only for shallow DI or UI wiring in Flutter. --- -_Last updated: August 19, 2025._ +_Last updated: August 20, 2025._ _Please see scenario source for details._ diff --git a/benchmark_di/REPORT.ru.md b/benchmark_di/REPORT.ru.md index 5af5eba..8535f02 100644 --- a/benchmark_di/REPORT.ru.md +++ b/benchmark_di/REPORT.ru.md @@ -19,30 +19,45 @@ ## Сравнительная таблица: chainCount=100, nestingDepth=100, repeat=5, warmup=2 (среднее время, мкс) -| Сценарий | cherrypick | get_it | riverpod | kiwi | -|------------------|------------|--------|----------|------| -| chainSingleton | 47.6 | 13.0 | 389.6 | 46.8 | -| chainFactory | 93.6 | 68.4 | 678.4 | 40.8 | -| register | 67.4 | 10.2 | 242.2 | 56.2 | -| named | 14.2 | 10.6 | 10.4 | 8.2 | -| override | 42.2 | 11.2 | 302.8 | 44.6 | -| chainAsync | 519.4 | 38.0 | 886.6 | – | +| Сценарий | cherrypick | get_it | riverpod | kiwi | yx_scope | +|------------------|------------|--------|----------|-------|----------| +| chainSingleton | 20.6 | 14.8 | 275.2 | 47.0 | 82.8 | +| chainFactory | 90.6 | 71.6 | 357.0 | 46.2 | 79.6 | +| register | 82.6 | 10.2 | 252.6 | 43.6 | 224.0 | +| named | 18.4 | 9.4 | 12.2 | 10.2 | 10.8 | +| override | 170.6 | 11.2 | 301.4 | 51.4 | 146.4 | +| chainAsync | 493.8 | 34.0 | 5,039.0 | – | 87.2 | + + +## Пиковое потребление памяти (Peak RSS, Кб) + +| Сценарий | cherrypick | get_it | riverpod | kiwi | yx_scope | +|------------------|------------|--------|----------|--------|----------| +| chainSingleton | 338,224 | 326,752| 301,856 | 195,520| 320,928 | +| chainFactory | 339,040 | 335,712| 304,832 | 319,952| 318,688 | +| register | 333,760 | 334,208| 300,368 | 327,968| 326,736 | +| named | 241,040 | 229,632| 280,144 | 271,872| 266,352 | +| override | 356,912 | 331,456| 329,808 | 369,104| 304,416 | +| chainAsync | 311,616 | 434,592| 301,168 | – | 328,912 | --- ## Краткий анализ и рекомендации -- **get_it** и **kiwi** — самые быстрые в большинстве синхронных сценариев. -- **cherrypick** надежен и быстр, только немного медленнее. -- **riverpod** заметно проигрывает на глубоко вложенных и async-графах. -- **Асинхронный сценарий**: get_it — абсолютный лидер, cherrypick и riverpod значительно медленнее, kiwi не поддерживает async. -- **named** lookup отрабатывает быстро во всех DI. +- **get_it** — абсолютный лидер по скорости и памяти на всех графах (минимальная задержка, небольшой peak RSS в любых цепочках). +- **kiwi** — минимальное потребление памяти в chainSingleton/Factory, но не для асинхронности. +- **yx_scope** — очень ровная производительность даже на сложных async/sync-цепях, иногда с пиком в памяти на override/register, но задержки всегда минимальны. +- **cherrypick** — стабильнее riverpod, но ощутимо уступает top-3 по латентности на длинных/async-графах; по памяти лучше yx_scope для override/named. +- **riverpod** — непригоден для глубоких/async-графов: память и время растут очень сильно. +- **Пиковое потребление памяти**: большинство DI держится в районе 320–340 Мб (большие цепи), на мелких named/factory — крайне мало. +- **Стабильность**: yx_scope и get_it показывают наименьшие скачки времени; у cherrypick иногда всплески на override/async, у riverpod — на async графе stddev почти равен mean! ### Рекомендации -- Используйте **get_it** или **kiwi** для максимальной производительности и простоты. -- **cherrypick** хорош для масштабируемых решений с небольшой задержкой. -- **riverpod** оправдан только для Flutter и простых графов. +- Используйте **get_it** (или **kiwi**, если не нужен async) для максимальной производительности и минимального пикового использования памяти. +- **yx_scope** — идеально для production-графов с миксом sync/async. +- **cherrypick** — хорошо для модульных и тестируемых приложений, если не требуется абсолютная “микросекундная” производительность. +- **riverpod** — только если граф плоский или нужно DI только для UI во Flutter. --- -_Обновлено: 19 августа 2025._ +_Обновлено: 20 августа 2025._