Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove inversify-express-utils from benchmark #436

Merged

Conversation

notaphplover
Copy link
Member

@notaphplover notaphplover commented Feb 24, 2025

Changed

  • Removed inversify-express-utils related benchmarks.

Motivation

With the current http core implementation, I am expecting a peer dependency conflict with inversify. inversify-express-utils require inversify@6 peer, but http core demands inverisfy@7. We already know inversify-express-utils are slow and therefore I consider the lesser evil to remove inversify-express-utils from the benchmarks and try to be faster than industry standard solutions such as nest.

@notaphplover notaphplover self-assigned this Feb 24, 2025
Copy link
Contributor

Benchmarks results:

[CJS] Running benchmarks...

Get service in singleton scope
┌─────────┬────────────────────┬──────────────────┬──────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name          │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼────────────────────┼──────────────────┼──────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0       │ 'inversifyCurrent''301.69 ± 1.11%''280.00 ± 10.00''3538313 ± 0.01%''3571429 ± 132275'     │ 3314672 │
│ 1       │ 'inversify6''1081.5 ± 1.91%''971.00 ± 19.00''998707 ± 0.02%''1029866 ± 20554'      │ 924631  │
│ 2       │ 'NestJS''307.58 ± 3.55%''281.00 ± 10.00''3514414 ± 0.01%''3558719 ± 122293'     │ 3251187 │
│ 3       │ 'tsyringe''318.98 ± 0.69%''300.00 ± 10.00''3320392 ± 0.01%''3333333 ± 107527'     │ 3134956 │
└─────────┴────────────────────┴──────────────────┴──────────────────┴────────────────────────┴────────────────────────┴─────────┘
inversifyCurrent vs inversify6 Speedup: 3.543x
inversifyCurrent vs NestJS Speedup: 1.007x
inversifyCurrent vs tsyringe Speedup: 1.066x

Get service in transient scope
┌─────────┬────────────────────┬──────────────────┬───────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name          │ Latency avg (ns) │ Latency med (ns)  │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼────────────────────┼──────────────────┼───────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0       │ 'inversifyCurrent''647.50 ± 0.56%''611.00 ± 10.00''1630332 ± 0.01%''1636661 ± 27232'      │ 1544408 │
│ 1       │ 'inversify6''5267.3 ± 3.11%''4849.0 ± 70.00''203335 ± 0.03%''206228 ± 3021'        │ 189851  │
│ 2       │ 'NestJS''9296.5 ± 1.83%''7935.0 ± 170.00''123053 ± 0.06%''126024 ± 2643'        │ 107567  │
│ 3       │ 'tsyringe''526.33 ± 2.97%''481.00 ± 10.00''2039504 ± 0.01%''2079002 ± 42342'      │ 1899954 │
└─────────┴────────────────────┴──────────────────┴───────────────────┴────────────────────────┴────────────────────────┴─────────┘
inversifyCurrent vs inversify6 Speedup: 8.018x
inversifyCurrent vs NestJS Speedup: 13.249x
inversifyCurrent vs tsyringe Speedup: 0.799x

Get complex service in singleton scope
┌─────────┬────────────────────┬──────────────────┬──────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name          │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼────────────────────┼──────────────────┼──────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0       │ 'inversifyCurrent''325.48 ± 2.05%''291.00 ± 10.00''3362416 ± 0.01%''3436426 ± 122293'     │ 3072355 │
│ 1       │ 'inversify6''1030.4 ± 0.57%''952.00 ± 10.00''1028432 ± 0.01%''1050420 ± 11151'      │ 970457  │
│ 2       │ 'NestJS''350.61 ± 0.76%''321.00 ± 10.00''3066996 ± 0.01%''3115265 ± 94117'      │ 2852178 │
│ 3       │ 'tsyringe''347.97 ± 2.99%''310.00 ± 10.00''3176129 ± 0.01%''3225806 ± 107527'     │ 2873785 │
└─────────┴────────────────────┴──────────────────┴──────────────────┴────────────────────────┴────────────────────────┴─────────┘
inversifyCurrent vs inversify6 Speedup: 3.269x
inversifyCurrent vs NestJS Speedup: 1.096x
inversifyCurrent vs tsyringe Speedup: 1.059x

Get complex service in transient scope
┌─────────┬────────────────────┬───────────────────┬──────────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name          │ Latency avg (ns)  │ Latency med (ns)     │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼────────────────────┼───────────────────┼──────────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0       │ 'inversifyCurrent''370246 ± 0.82%''357009 ± 5642.00''2754 ± 0.36%''2801 ± 45'            │ 2701    │
│ 1       │ 'inversify6''4870359 ± 1.28%''4570413 ± 84203.00''207 ± 1.18%''219 ± 4'              │ 206     │
│ 2       │ 'NestJS''60781 ± 1.48%''54041 ± 671.00''18040 ± 0.17%''18504 ± 231'          │ 16453   │
│ 3       │ 'tsyringe''244144 ± 0.81%''228418 ± 1272.00''4227 ± 0.37%''4378 ± 25'            │ 4096    │
└─────────┴────────────────────┴───────────────────┴──────────────────────┴────────────────────────┴────────────────────────┴─────────┘
inversifyCurrent vs inversify6 Speedup: 13.304x
inversifyCurrent vs NestJS Speedup: 0.153x
inversifyCurrent vs tsyringe Speedup: 0.651x
[ESM] Running benchmarks...

Get service in singleton scope
┌─────────┬────────────────────┬──────────────────┬──────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name          │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼────────────────────┼──────────────────┼──────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0       │ 'inversifyCurrent''253.40 ± 0.15%''241.00 ± 10.00''4057647 ± 0.01%''4149378 ± 165314'     │ 3946393 │
│ 1       │ 'inversify6''924.81 ± 3.57%''841.00 ± 20.00''1174625 ± 0.02%''1189061 ± 28966'      │ 1081309 │
│ 2       │ 'NestJS''306.53 ± 0.46%''290.00 ± 9.00''3437490 ± 0.01%''3448276 ± 110443'     │ 3262369 │
│ 3       │ 'tsyringe''308.34 ± 1.34%''280.00 ± 9.00''3525021 ± 0.01%''3571429 ± 118608'     │ 3243194 │
└─────────┴────────────────────┴──────────────────┴──────────────────┴────────────────────────┴────────────────────────┴─────────┘
inversifyCurrent vs inversify6 Speedup: 3.454x
inversifyCurrent vs NestJS Speedup: 1.180x
inversifyCurrent vs tsyringe Speedup: 1.151x

Get service in transient scope
┌─────────┬────────────────────┬──────────────────┬───────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name          │ Latency avg (ns) │ Latency med (ns)  │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼────────────────────┼──────────────────┼───────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0       │ 'inversifyCurrent''507.91 ± 0.29%''481.00 ± 10.00''2036053 ± 0.01%''2079002 ± 42342'      │ 1968848 │
│ 1       │ 'inversify6''5057.3 ± 4.32%''4649.0 ± 71.00''211942 ± 0.03%''215100 ± 3336'        │ 197733  │
│ 2       │ 'NestJS''8987.3 ± 1.49%''7835.0 ± 170.00''124800 ± 0.06%''127632 ± 2710'        │ 111268  │
│ 3       │ 'tsyringe''509.93 ± 2.56%''470.00 ± 9.00''2117207 ± 0.01%''2127660 ± 41538'      │ 1964791 │
└─────────┴────────────────────┴──────────────────┴───────────────────┴────────────────────────┴────────────────────────┴─────────┘
inversifyCurrent vs inversify6 Speedup: 9.607x
inversifyCurrent vs NestJS Speedup: 16.315x
inversifyCurrent vs tsyringe Speedup: 0.962x

Get complex service in singleton scope
┌─────────┬────────────────────┬──────────────────┬──────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name          │ Latency avg (ns) │ Latency med (ns) │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼────────────────────┼──────────────────┼──────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0       │ 'inversifyCurrent''263.77 ± 1.70%''251.00 ± 9.00''3913284 ± 0.01%''3984064 ± 137910'     │ 3791124 │
│ 1       │ 'inversify6''926.80 ± 3.74%''822.00 ± 10.00''1189901 ± 0.01%''1216545 ± 14982'      │ 1078983 │
│ 2       │ 'NestJS''351.25 ± 3.03%''311.00 ± 9.00''3133114 ± 0.01%''3215434 ± 90434'      │ 2846956 │
│ 3       │ 'tsyringe''328.47 ± 3.55%''291.00 ± 9.00''3342886 ± 0.01%''3436426 ± 103093'     │ 3044454 │
└─────────┴────────────────────┴──────────────────┴──────────────────┴────────────────────────┴────────────────────────┴─────────┘
inversifyCurrent vs inversify6 Speedup: 3.289x
inversifyCurrent vs NestJS Speedup: 1.249x
inversifyCurrent vs tsyringe Speedup: 1.171x

Get complex service in transient scope
┌─────────┬────────────────────┬───────────────────┬───────────────────────┬────────────────────────┬────────────────────────┬─────────┐
│ (index) │ Task name          │ Latency avg (ns)  │ Latency med (ns)      │ Throughput avg (ops/s) │ Throughput med (ops/s) │ Samples │
├─────────┼────────────────────┼───────────────────┼───────────────────────┼────────────────────────┼────────────────────────┼─────────┤
│ 0       │ 'inversifyCurrent''255632 ± 0.55%''245881 ± 1713.00''3964 ± 0.26%''4067 ± 29'            │ 3912    │
│ 1       │ 'inversify6''4661681 ± 0.90%''4717341 ± 315813.00''215 ± 0.90%''212 ± 14'             │ 215     │
│ 2       │ 'NestJS''61124 ± 1.28%''55184 ± 732.00''17666 ± 0.16%''18121 ± 243'          │ 16361   │
│ 3       │ 'tsyringe''221804 ± 0.49%''213391 ± 2054.00''4575 ± 0.26%''4686 ± 46'            │ 4509    │
└─────────┴────────────────────┴───────────────────┴───────────────────────┴────────────────────────┴────────────────────────┴─────────┘
inversifyCurrent vs inversify6 Speedup: 18.398x
inversifyCurrent vs NestJS Speedup: 0.224x
inversifyCurrent vs tsyringe Speedup: 0.866x

@Adrianmjim Adrianmjim merged commit 0c36134 into main Feb 24, 2025
8 checks passed
@Adrianmjim Adrianmjim deleted the chore/remove-inversify-expres-utils-from-http-benchmarks branch February 24, 2025 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants