-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathmetadata.rs
More file actions
35 lines (27 loc) · 1.09 KB
/
metadata.rs
File metadata and controls
35 lines (27 loc) · 1.09 KB
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
use anyhow::Context;
use serde::{Deserialize, Serialize};
use std::path::Path;
use crate::fifo::MarkerType;
#[derive(Serialize, Deserialize)]
pub struct PerfMetadata {
/// The version of this metadata format.
pub version: u64,
/// Name and version of the integration
pub integration: (String, String),
/// The URIs of the benchmarks with the timestamps they were executed at.
pub uri_by_ts: Vec<(u64, String)>,
/// Modules that should be ignored and removed from the folded trace and callgraph (e.g. python interpreter)
pub ignored_modules: Vec<(String, u64, u64)>,
/// Marker for certain regions in the profiling data
pub markers: Vec<MarkerType>,
}
impl PerfMetadata {
pub fn from_reader<R: std::io::Read>(reader: R) -> anyhow::Result<Self> {
serde_json::from_reader(reader).context("Could not parse perf metadata from JSON")
}
pub fn save_to<P: AsRef<Path>>(&self, path: P) -> anyhow::Result<()> {
let file = std::fs::File::create(path.as_ref().join("perf.metadata"))?;
serde_json::to_writer(file, self)?;
Ok(())
}
}