-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -649,6 +649,86 @@ mod tests { | |
); | ||
} | ||
|
||
// To generate this revision, a v9 revision of the rust toolchain was | ||
// created, and "rustup toolchain link" was used to name it "bespoke". | ||
// Then, the following commands were executed: | ||
// | ||
// # Make a small test binary and profile it. | ||
// cargo new --bin testbinary | ||
// cargo +bespoke rustc --bin testbinary -- -Zself-profile | ||
// | ||
// # Gzip the output profdata. | ||
// gzip testbinary-...mm_profdata | ||
// mv testbinary-...mm_profdata.gz v9.mm_profdata.gz | ||
#[test] | ||
fn can_read_v9_profdata_files() { | ||
let (data, file_format_version) = | ||
read_data_and_version("tests/profdata/v9.mm_profdata.gz"); | ||
assert_eq!(file_format_version, file_formats::v9::FILE_FORMAT); | ||
let profiling_data = ProfilingData::from_paged_buffer(data, None) | ||
.expect("Creating the profiling data failed"); | ||
let grouped_events = group_events(&profiling_data); | ||
let event_kinds = grouped_events | ||
.keys() | ||
.map(|k| k.as_str()) | ||
.collect::<HashSet<_>>(); | ||
let expect_event_kinds = vec![ | ||
"GenericActivity", | ||
"IncrementalResultHashing", | ||
"Query", | ||
"ArtifactSize", | ||
This comment has been minimized.
Sorry, something went wrong. |
||
] | ||
.into_iter() | ||
.collect::<HashSet<_>>(); | ||
assert_eq!(event_kinds, expect_event_kinds); | ||
|
||
let generic_activity_len = 5125; | ||
let incremental_hashing_len = 1844; | ||
let query_len = 1877; | ||
let artifact_size_len = 24; | ||
assert_eq!( | ||
grouped_events["GenericActivity"].len(), | ||
generic_activity_len | ||
); | ||
assert_eq!( | ||
grouped_events["IncrementalResultHashing"].len(), | ||
incremental_hashing_len | ||
); | ||
assert_eq!(grouped_events["Query"].len(), query_len); | ||
assert_eq!(grouped_events["ArtifactSize"].len(), artifact_size_len); | ||
|
||
assert_eq!( | ||
grouped_events["GenericActivity"][generic_activity_len / 2].label, | ||
"metadata_decode_entry_item_attrs" | ||
); | ||
assert_eq!( | ||
grouped_events["GenericActivity"][generic_activity_len / 2].duration(), | ||
Some(Duration::from_nanos(376)) | ||
); | ||
|
||
assert_eq!( | ||
grouped_events["IncrementalResultHashing"][incremental_hashing_len - 1].label, | ||
"crate_hash" | ||
); | ||
assert_eq!( | ||
grouped_events["IncrementalResultHashing"][incremental_hashing_len - 1].duration(), | ||
Some(Duration::from_nanos(461)) | ||
); | ||
|
||
assert_eq!(grouped_events["Query"][0].label, "registered_tools"); | ||
assert_eq!( | ||
grouped_events["Query"][0].duration(), | ||
Some(Duration::from_nanos(45077)) | ||
); | ||
|
||
assert_eq!( | ||
This comment has been minimized.
Sorry, something went wrong.
smklein
Author
Contributor
|
||
grouped_events["ArtifactSize"][0].label, | ||
"codegen_unit_size_estimate" | ||
); | ||
assert_eq!(grouped_events["ArtifactSize"][0].duration(), None); | ||
assert_eq!(grouped_events["ArtifactSize"][0].integer(), Some(3)); | ||
} | ||
|
||
fn read_data_and_version(file_path: &str) -> (Vec<u8>, u32) { | ||
let data = std::fs::read(file_path).expect("Test data not found"); | ||
let mut gz = flate2::read::GzDecoder::new(&data[..]); | ||
|
Binary file not shown.
Most of this test was just copied from the v8 version, but
ArtifactSize
seems new?