diff options
| author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2022-04-24 16:45:56 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-24 21:45:56 +0200 |
| commit | e2fba7b967cba1e690ad24e12f9db1d329a0c938 (patch) | |
| tree | 03c95d25b686924d7aab3bb2b6e2eb7ccc1cc62d /ext/http/benches | |
| parent | 8107a79b391d94db7fbf44e2529c650fe3adaf27 (diff) | |
perf(ext/http): faster is_content_compressible (#14383)
Cleanup + benches
Diffstat (limited to 'ext/http/benches')
| -rw-r--r-- | ext/http/benches/compressible.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ext/http/benches/compressible.rs b/ext/http/benches/compressible.rs new file mode 100644 index 000000000..bdd3bcad8 --- /dev/null +++ b/ext/http/benches/compressible.rs @@ -0,0 +1,37 @@ +// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. +use bencher::{benchmark_group, benchmark_main, Bencher}; +use deno_http::compressible::is_content_compressible; + +fn compressible_simple_hit(b: &mut Bencher) { + b.iter(|| { + is_content_compressible("text/plain"); + }) +} + +fn compressible_complex_hit(b: &mut Bencher) { + b.iter(|| { + is_content_compressible("text/PlAIn; charset=utf-8"); + }) +} + +fn compressible_simple_miss(b: &mut Bencher) { + b.iter(|| { + is_content_compressible("text/fake"); + }) +} + +fn compressible_complex_miss(b: &mut Bencher) { + b.iter(|| { + is_content_compressible("text/fake;charset=utf-8"); + }) +} + +benchmark_group!( + benches, + compressible_simple_hit, + compressible_complex_hit, + compressible_simple_miss, + compressible_complex_miss, +); + +benchmark_main!(benches); |
