summaryrefslogtreecommitdiff
path: root/cli/bench/metrics.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-07-11 20:58:32 +0200
committerGitHub <noreply@github.com>2022-07-11 20:58:32 +0200
commit88c36fd4140f65c2133c9b5836bc807a6c22b35a (patch)
treea47c3ce6cf289274894f43d36d6392f1f15ffac6 /cli/bench/metrics.rs
parent989c72313078e71b60e22902f8a3abc67d085187 (diff)
benchmarks: fix exec_time and latency benchmarks (#15155)
Diffstat (limited to 'cli/bench/metrics.rs')
-rw-r--r--cli/bench/metrics.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/cli/bench/metrics.rs b/cli/bench/metrics.rs
index c49ca9020..964fdde4b 100644
--- a/cli/bench/metrics.rs
+++ b/cli/bench/metrics.rs
@@ -17,9 +17,9 @@ static GIT_HASH: Lazy<String> = Lazy::new(|| {
});
#[derive(serde::Serialize)]
-struct Metric {
+struct Metric<T: serde::Serialize> {
name: String,
- value: i64,
+ value: T,
sha1: String,
#[serde(rename = "type")]
type_: String,
@@ -62,7 +62,12 @@ impl Reporter {
}
}
- pub fn write_one(&mut self, type_: &str, name: &str, value: i64) {
+ pub fn write_one<T: serde::Serialize>(
+ &mut self,
+ type_: &str,
+ name: &str,
+ value: T,
+ ) {
self
.wtr
.serialize(Metric {
@@ -75,7 +80,11 @@ impl Reporter {
.unwrap();
}
- pub fn write(&mut self, type_: &str, hashmap: &HashMap<String, i64>) {
+ pub fn write<T: serde::Serialize + Copy>(
+ &mut self,
+ type_: &str,
+ hashmap: &HashMap<String, T>,
+ ) {
for (name, value) in hashmap {
self.write_one(type_, name, *value);
}