Skip to content

Commit aca3274

Browse files
committed
Add rustc info to timing output.
1 parent 0664484 commit aca3274

File tree

2 files changed

+57
-39
lines changed

2 files changed

+57
-39
lines changed

src/cargo/core/compiler/job_queue.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
133133
pub fn new(bcx: &BuildContext<'a, 'cfg>, root_units: &[Unit<'a>]) -> JobQueue<'a, 'cfg> {
134134
let (tx, rx) = channel();
135135
let progress = Progress::with_style("Building", ProgressStyle::Ratio, bcx.config);
136-
let profile = if bcx.build_config.release {
137-
"release"
138-
} else {
139-
"dev"
140-
}
141-
.to_string();
142-
let timings = Timings::new(bcx.config, root_units, profile);
136+
let timings = Timings::new(bcx, root_units);
143137
JobQueue {
144138
queue: DependencyQueue::new(),
145139
tx,

src/cargo/core/compiler/timings.rs

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//! This module implements some simple tracking information for timing of how
44
//! long it takes for different units to compile.
55
use super::{CompileMode, Unit};
6+
use crate::core::compiler::BuildContext;
67
use crate::core::PackageId;
78
use crate::util::machine_message::{self, Message};
89
use crate::util::{CargoResult, Config};
@@ -24,6 +25,8 @@ pub struct Timings<'a, 'cfg> {
2425
start: Instant,
2526
/// A rendered string of when compilation started.
2627
start_str: String,
28+
/// Some information to display about rustc.
29+
rustc_info: String,
2730
/// A summary of the root units.
2831
///
2932
/// Tuples of `(package_description, target_descrptions)`.
@@ -76,11 +79,7 @@ struct Concurrency {
7679
}
7780

7881
impl<'a, 'cfg> Timings<'a, 'cfg> {
79-
pub fn new(
80-
config: &'cfg Config,
81-
root_units: &[Unit<'_>],
82-
profile: String,
83-
) -> Timings<'a, 'cfg> {
82+
pub fn new(bcx: &BuildContext<'a, 'cfg>, root_units: &[Unit<'_>]) -> Timings<'a, 'cfg> {
8483
let mut root_map: HashMap<PackageId, Vec<String>> = HashMap::new();
8584
for unit in root_units {
8685
let target_desc = unit.target.description_named();
@@ -98,20 +97,28 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
9897
.collect();
9998
let start_str = format!("{}", humantime::format_rfc3339_seconds(SystemTime::now()));
10099
let has_report = |what| {
101-
config
100+
bcx.config
102101
.cli_unstable()
103102
.timings
104103
.as_ref()
105104
.map_or(false, |t| t.iter().any(|opt| opt == what))
106105
};
106+
let rustc_info = render_rustc_info(bcx);
107+
let profile = if bcx.build_config.release {
108+
"release"
109+
} else {
110+
"dev"
111+
}
112+
.to_string();
107113

108114
Timings {
109-
config,
115+
config: bcx.config,
110116
report_html: has_report("html"),
111117
report_info: has_report("info"),
112118
report_json: has_report("json"),
113-
start: config.creation_time(),
119+
start: bcx.config.creation_time(),
114120
start_str,
121+
rustc_info,
115122
root_targets,
116123
profile,
117124
total_fresh: 0,
@@ -270,30 +277,27 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
270277
<tr>
271278
<td>Profile:</td><td>{}</td>
272279
</tr>
273-
<tr>
274-
<td>Fresh units:</td>
275-
<td>{}</td>
276-
</tr>
277-
<tr>
278-
<td>Dirty units:</td>
279-
<td>{}</td>
280-
</tr>
281-
<tr>
282-
<td>Total units:</td>
283-
<td>{}</td>
284-
</tr>
285-
<tr>
286-
<td>Max concurrency:</td>
287-
<td>{}</td>
288-
</tr>
289-
<tr>
290-
<td>Build start:</td>
291-
<td>{}</td>
292-
</tr>
293-
<tr>
294-
<td>Total time:</td>
295-
<td>{}</td>
296-
</tr>
280+
<tr>
281+
<td>Fresh units:</td><td>{}</td>
282+
</tr>
283+
<tr>
284+
<td>Dirty units:</td><td>{}</td>
285+
</tr>
286+
<tr>
287+
<td>Total units:</td><td>{}</td>
288+
</tr>
289+
<tr>
290+
<td>Max concurrency:</td><td>{}</td>
291+
</tr>
292+
<tr>
293+
<td>Build start:</td><td>{}</td>
294+
</tr>
295+
<tr>
296+
<td>Total time:</td><td>{}</td>
297+
</tr>
298+
<tr>
299+
<td>rustc:</td><td>{}</td>
300+
</tr>
297301
298302
</table>
299303
"#,
@@ -305,6 +309,7 @@ impl<'a, 'cfg> Timings<'a, 'cfg> {
305309
max_concurrency,
306310
self.start_str,
307311
total_time,
312+
self.rustc_info,
308313
)?;
309314
Ok(())
310315
}
@@ -674,6 +679,24 @@ fn draw_graph_axes(f: &mut File, graph_height: u32, duration: u32) -> CargoResul
674679
Ok(graph_width)
675680
}
676681

682+
fn render_rustc_info(bcx: &BuildContext<'_, '_>) -> String {
683+
let version = bcx
684+
.rustc
685+
.verbose_version
686+
.lines()
687+
.next()
688+
.expect("rustc version");
689+
let requested_target = bcx
690+
.build_config
691+
.requested_target
692+
.as_ref()
693+
.map_or("Host", String::as_str);
694+
format!(
695+
"{}<br>Host: {}<br>Target: {}",
696+
version, bcx.rustc.host, requested_target
697+
)
698+
}
699+
677700
static HTML_TMPL: &str = r#"
678701
<html>
679702
<head>
@@ -801,6 +824,7 @@ h1 {
801824
}
802825
803826
.summary-table td:first-child {
827+
vertical-align: top;
804828
text-align: right;
805829
}
806830

0 commit comments

Comments
 (0)