Skip to content

jub0bs/cors-benchmarks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Benchmarks comparing rs/cors and jub0bs/cors

This repo contains benchmarks (run with Go v1.23.0) that compare the performance of two CORS middleware libraries:

Running the benchmarks

Run the following commands in your shell (preferably on an idle machine):

git clone https://github.com/jub0bs/cors-benchmarks
cd cors-benchmarks
go test -run ^$ -bench . -count 10 > new.txt
benchstat -col "/mw@(rs-cors jub0bs-cors)" -row "/req" new.txt

Results

goos: darwin
goarch: amd64
pkg: github.com/jub0bs/cors-benchmarks
cpu: Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
                              │   rs-cors    │             jub0bs-cors             │
                              │    sec/op    │   sec/op     vs base                │
single_vs_actual                642.4n ±  2%   685.5n ± 1%   +6.72% (p=0.000 n=10)
multiple_vs_actual              662.0n ±  1%   709.6n ± 1%   +7.20% (p=0.000 n=10)
pathological_vs_actual          731.4n ±  1%   820.7n ± 1%  +12.19% (p=0.000 n=10)
many_vs_actual                  700.5n ±  1%   686.4n ± 1%   -2.01% (p=0.000 n=10)
any_vs_actual                   674.9n ± 14%   675.1n ± 3%        ~ (p=0.631 n=10)
all_CORS_headers_vs_actual      730.7n ±  3%   814.8n ± 3%  +11.52% (p=0.000 n=10)
single_vs_preflight             561.0n ±  2%   519.6n ± 1%   -7.37% (p=0.000 n=10)
multiple_vs_preflight           566.9n ±  2%   529.9n ± 2%   -6.54% (p=0.000 n=10)
pathological_vs_preflight       562.9n ±  2%   597.4n ± 2%   +6.14% (p=0.000 n=10)
many_vs_preflight               523.4n ±  2%   465.1n ± 2%  -11.14% (p=0.000 n=10)
any_vs_preflight                558.1n ±  0%   516.2n ± 5%   -7.52% (p=0.000 n=10)
ACRH_vs_preflight               524.2n ±  3%   472.7n ± 3%   -9.82% (p=0.000 n=10)
all_CORS_headers_vs_preflight   538.9n ±  4%   531.1n ± 3%        ~ (p=0.052 n=10)
malicious_ACRH_vs_preflight     570.0n ±  3%   529.3n ± 3%   -7.13% (p=0.000 n=10)
geomean                         606.2n         600.4n        -0.95%

                              │   rs-cors    │              jub0bs-cors              │
                              │     B/op     │     B/op      vs base                 │
single_vs_actual                1.047Ki ± 0%   1.047Ki ± 0%       ~ (p=1.000 n=10) ¹
multiple_vs_actual              1.047Ki ± 0%   1.047Ki ± 0%       ~ (p=1.000 n=10) ¹
pathological_vs_actual          1.047Ki ± 0%   1.031Ki ± 0%  -1.49% (p=0.000 n=10)
many_vs_actual                  1.047Ki ± 0%   1.031Ki ± 0%  -1.49% (p=0.000 n=10)
any_vs_actual                   1.047Ki ± 0%   1.031Ki ± 0%  -1.49% (p=0.000 n=10)
all_CORS_headers_vs_actual      1.062Ki ± 0%   1.078Ki ± 0%  +1.47% (p=0.000 n=10)
single_vs_preflight               976.0 ± 0%     944.0 ± 0%  -3.28% (p=0.000 n=10)
multiple_vs_preflight             976.0 ± 0%     944.0 ± 0%  -3.28% (p=0.000 n=10)
pathological_vs_preflight         960.0 ± 0%     928.0 ± 0%  -3.33% (p=0.000 n=10)
many_vs_preflight                 960.0 ± 0%     928.0 ± 0%  -3.33% (p=0.000 n=10)
any_vs_preflight                  976.0 ± 0%     944.0 ± 0%  -3.28% (p=0.000 n=10)
ACRH_vs_preflight                 968.0 ± 0%     928.0 ± 0%  -4.13% (p=0.000 n=10)
all_CORS_headers_vs_preflight     968.0 ± 0%     928.0 ± 0%  -4.13% (p=0.000 n=10)
malicious_ACRH_vs_preflight       968.0 ± 0%     928.0 ± 0%  -4.13% (p=0.000 n=10)
geomean                          1012.9          989.7       -2.29%
¹ all samples are equal

                              │  rs-cors   │             jub0bs-cors              │
                              │ allocs/op  │ allocs/op   vs base                  │
single_vs_actual                11.00 ± 0%   11.00 ± 0%        ~ (p=1.000 n=10) ¹
multiple_vs_actual              11.00 ± 0%   11.00 ± 0%        ~ (p=1.000 n=10) ¹
pathological_vs_actual          12.00 ± 0%   11.00 ± 0%   -8.33% (p=0.000 n=10)
many_vs_actual                  12.00 ± 0%   11.00 ± 0%   -8.33% (p=0.000 n=10)
any_vs_actual                   11.00 ± 0%   11.00 ± 0%        ~ (p=1.000 n=10) ¹
all_CORS_headers_vs_actual      11.00 ± 0%   12.00 ± 0%   +9.09% (p=0.000 n=10)
single_vs_preflight             8.000 ± 0%   7.000 ± 0%  -12.50% (p=0.000 n=10)
multiple_vs_preflight           8.000 ± 0%   7.000 ± 0%  -12.50% (p=0.000 n=10)
pathological_vs_preflight       9.000 ± 0%   7.000 ± 0%  -22.22% (p=0.000 n=10)
many_vs_preflight               9.000 ± 0%   7.000 ± 0%  -22.22% (p=0.000 n=10)
any_vs_preflight                8.000 ± 0%   7.000 ± 0%  -12.50% (p=0.000 n=10)
ACRH_vs_preflight               9.000 ± 0%   7.000 ± 0%  -22.22% (p=0.000 n=10)
all_CORS_headers_vs_preflight   9.000 ± 0%   7.000 ± 0%  -22.22% (p=0.000 n=10)
malicious_ACRH_vs_preflight     9.000 ± 0%   7.000 ± 0%  -22.22% (p=0.000 n=10)
geomean                         9.683        8.549       -11.71%
¹ all samples are equal

For more details about the benchmark labeled "malicious_ACRH_vs_preflight", see rs/cors#170.

About

Microbenchmarks pitting jub0bs/cors against rs/cors

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages