Auto merge of #110481 - matthiaskrgr:rollup-phkkgm9, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #109981 (Set commit information environment variables when building tools) - #110348 (Add list of supported disambiguators and suffixes for intra-doc links in the rustdoc book) - #110409 (Don't use `serde_json` to serialize a simple JSON object) - #110442 (Avoid including dry run steps in the build metrics) - #110450 (rustdoc: Fix invalid handling of nested items with `--document-private-items`) - #110461 (Use `Item::expect_*` and `ImplItem::expect_*` more) - #110465 (Assure everyone that `has_type_flags` is fast) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
74864fa496
27 changed files with 244 additions and 70 deletions
|
@ -87,6 +87,7 @@ use crate::fx::FxHashMap;
|
|||
use std::borrow::Borrow;
|
||||
use std::collections::hash_map::Entry;
|
||||
use std::error::Error;
|
||||
use std::fmt::Display;
|
||||
use std::fs;
|
||||
use std::intrinsics::unlikely;
|
||||
use std::path::Path;
|
||||
|
@ -97,7 +98,6 @@ use std::time::{Duration, Instant};
|
|||
pub use measureme::EventId;
|
||||
use measureme::{EventIdBuilder, Profiler, SerializableString, StringId};
|
||||
use parking_lot::RwLock;
|
||||
use serde_json::json;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
bitflags::bitflags! {
|
||||
|
@ -763,6 +763,31 @@ impl Drop for VerboseTimingGuard<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
struct JsonTimePassesEntry<'a> {
|
||||
pass: &'a str,
|
||||
time: f64,
|
||||
start_rss: Option<usize>,
|
||||
end_rss: Option<usize>,
|
||||
}
|
||||
|
||||
impl Display for JsonTimePassesEntry<'_> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let Self { pass: what, time, start_rss, end_rss } = self;
|
||||
write!(f, r#"{{"pass":"{what}","time":{time},"rss_start":"#).unwrap();
|
||||
match start_rss {
|
||||
Some(rss) => write!(f, "{rss}")?,
|
||||
None => write!(f, "null")?,
|
||||
}
|
||||
write!(f, r#","rss_end":"#)?;
|
||||
match end_rss {
|
||||
Some(rss) => write!(f, "{rss}")?,
|
||||
None => write!(f, "null")?,
|
||||
}
|
||||
write!(f, "}}")?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_time_passes_entry(
|
||||
what: &str,
|
||||
dur: Duration,
|
||||
|
@ -772,13 +797,10 @@ pub fn print_time_passes_entry(
|
|||
) {
|
||||
match format {
|
||||
TimePassesFormat::Json => {
|
||||
let json = json!({
|
||||
"pass": what,
|
||||
"time": dur.as_secs_f64(),
|
||||
"rss_start": start_rss,
|
||||
"rss_end": end_rss,
|
||||
});
|
||||
eprintln!("time: {json}");
|
||||
let entry =
|
||||
JsonTimePassesEntry { pass: what, time: dur.as_secs_f64(), start_rss, end_rss };
|
||||
|
||||
eprintln!(r#"time: {entry}"#);
|
||||
return;
|
||||
}
|
||||
TimePassesFormat::Text => (),
|
||||
|
@ -894,3 +916,6 @@ cfg_if! {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
|
19
compiler/rustc_data_structures/src/profiling/tests.rs
Normal file
19
compiler/rustc_data_structures/src/profiling/tests.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
use super::JsonTimePassesEntry;
|
||||
|
||||
#[test]
|
||||
fn with_rss() {
|
||||
let entry =
|
||||
JsonTimePassesEntry { pass: "typeck", time: 56.1, start_rss: Some(10), end_rss: Some(20) };
|
||||
|
||||
assert_eq!(entry.to_string(), r#"{"pass":"typeck","time":56.1,"rss_start":10,"rss_end":20}"#)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_rss() {
|
||||
let entry = JsonTimePassesEntry { pass: "typeck", time: 56.1, start_rss: None, end_rss: None };
|
||||
|
||||
assert_eq!(
|
||||
entry.to_string(),
|
||||
r#"{"pass":"typeck","time":56.1,"rss_start":null,"rss_end":null}"#
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue