|
1 | 1 | // Benchmark inspired by |
2 | 2 | // https://github.com/tikv/rust-prometheus/blob/ab1ca7285d3463504381a5025ae1951e020d6796/benches/text_encoder.rs:write |
3 | 3 |
|
4 | | -use criterion::{black_box, criterion_group, criterion_main, Criterion}; |
5 | | -use prometheus_client::encoding::prometheus_protobuf; |
6 | | -use prometheus_client::metrics::counter::Counter; |
7 | | -use prometheus_client::metrics::family::Family; |
8 | | -use prometheus_client::metrics::histogram::{exponential_buckets, Histogram}; |
9 | | -use prometheus_client::registry::Registry; |
| 4 | +use criterion::{Criterion, black_box, criterion_group, criterion_main}; |
| 5 | +use prometheus_client::{ |
| 6 | + encoding::prometheus_protobuf, |
| 7 | + metrics::{ |
| 8 | + counter::Counter, |
| 9 | + family::Family, |
| 10 | + histogram::{Histogram, exponential_buckets}, |
| 11 | + }, |
| 12 | + registry::Registry, |
| 13 | +}; |
10 | 14 | use prometheus_client_derive_encode::{EncodeLabelSet, EncodeLabelValue}; |
11 | 15 |
|
12 | 16 | pub fn proto(c: &mut Criterion) { |
13 | 17 | c.bench_function("encode", |b| { |
14 | | - #[derive(Clone, Hash, PartialEq, Eq, EncodeLabelSet, Debug)] |
| 18 | + #[derive(Clone, Hash, PartialEq, Eq, EncodeLabelSet, Debug, PartialOrd, Ord)] |
15 | 19 | struct CounterLabels { |
16 | 20 | path: String, |
17 | 21 | method: Method, |
18 | 22 | some_number: u64, |
19 | 23 | } |
20 | 24 |
|
21 | | - #[derive(Clone, Hash, PartialEq, Eq, EncodeLabelValue, Debug)] |
| 25 | + #[derive(Clone, Hash, PartialEq, Eq, EncodeLabelValue, Debug, PartialOrd, Ord)] |
22 | 26 | enum Method { |
23 | 27 | Get, |
24 | 28 | #[allow(dead_code)] |
25 | 29 | Put, |
26 | 30 | } |
27 | 31 |
|
28 | | - #[derive(Clone, Hash, PartialEq, Eq, EncodeLabelSet, Debug)] |
| 32 | + #[derive(Clone, Hash, PartialEq, Eq, EncodeLabelSet, Debug, PartialOrd, Ord)] |
29 | 33 | struct HistogramLabels { |
30 | 34 | region: Region, |
31 | 35 | } |
32 | 36 |
|
33 | | - #[derive(Clone, Hash, PartialEq, Eq, EncodeLabelValue, Debug)] |
| 37 | + #[derive(Clone, Hash, PartialEq, Eq, EncodeLabelValue, Debug, PartialOrd, Ord)] |
34 | 38 | enum Region { |
35 | 39 | Africa, |
36 | 40 | #[allow(dead_code)] |
|
0 commit comments