summaryrefslogtreecommitdiff
path: root/ext/http/benches/compressible.rs
blob: 5ac09cb8bbadc576ad5a8fe39441f46ca9e53533 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
use bencher::benchmark_group;
use bencher::benchmark_main;
use bencher::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);