Skip to content

Commit 60c2e9a

Browse files
committed
Fix tidy
1 parent 97ab37e commit 60c2e9a

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

src/librustc/util/profiling.rs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ impl CategoryData {
9393
($name:tt, $rustic_name:ident) => {
9494
let (hits, total) = self.query_counts.$rustic_name;
9595
let (hits, total) = if total > 0 {
96-
(format!("{:.2}", (((hits as f32) / (total as f32)) * 100.0)), total.to_string())
96+
(format!("{:.2}",
97+
(((hits as f32) / (total as f32)) * 100.0)), total.to_string())
9798
} else {
9899
("".into(), "".into())
99100
};
@@ -109,8 +110,10 @@ impl CategoryData {
109110
};
110111
}
111112

112-
writeln!(lock, "| Phase | Time (ms) | Queries | Hits (%) |").unwrap();
113-
writeln!(lock, "| ---------------- | -------------- | -------------- | -------- |").unwrap();
113+
writeln!(lock, "| Phase | Time (ms) | Queries | Hits (%) |")
114+
.unwrap();
115+
writeln!(lock, "| ---------------- | -------------- | -------------- | -------- |")
116+
.unwrap();
114117

115118
p!("Parsing", parsing);
116119
p!("Expansion", expansion);
@@ -126,7 +129,9 @@ impl CategoryData {
126129
($category:tt, $rustic_name:ident) => {{
127130
let (hits, total) = self.query_counts.$rustic_name;
128131

129-
format!("{{ \"category\": {}, \"time_ms\": {}, \"query_count\": {}, \"query_hits\": {} }}",
132+
format!(
133+
"{{ \"category\": {}, \"time_ms\": {},
134+
\"query_count\": {}, \"query_hits\": {} }}",
130135
stringify!($category),
131136
self.times.$rustic_name / 1_000_000,
132137
total,
@@ -209,9 +214,9 @@ impl SelfProfiler {
209214
pub fn end_activity(&mut self, category: ProfileCategory) {
210215
match self.timer_stack.pop() {
211216
None => bug!("end_activity() was called but there was no running activity"),
212-
Some(c) =>
217+
Some(c) =>
213218
assert!(
214-
c == category,
219+
c == category,
215220
"end_activity() was called but a different activity was running"),
216221
}
217222

@@ -223,7 +228,8 @@ impl SelfProfiler {
223228
}
224229
}
225230

226-
//the new timer is different than the previous, so record the elapsed time and start a new timer
231+
//the new timer is different than the previous,
232+
//so record the elapsed time and start a new timer
227233
let elapsed = self.stop_timer();
228234
let new_time = self.data.times.get(category) + elapsed;
229235
self.data.times.set(category, new_time);
@@ -240,12 +246,18 @@ impl SelfProfiler {
240246
pub fn print_results(&mut self, opts: &Options) {
241247
self.end_activity(ProfileCategory::Other);
242248

243-
assert!(self.timer_stack.is_empty(), "there were timers running when print_results() was called");
249+
assert!(
250+
self.timer_stack.is_empty(),
251+
"there were timers running when print_results() was called");
244252

245253
let out = io::stdout();
246254
let mut lock = out.lock();
247255

248-
let crate_name = opts.crate_name.as_ref().map(|n| format!(" for {}", n)).unwrap_or_default();
256+
let crate_name =
257+
opts.crate_name
258+
.as_ref()
259+
.map(|n| format!(" for {}", n))
260+
.unwrap_or_default();
249261

250262
writeln!(lock, "Self profiling results{}:", crate_name).unwrap();
251263
writeln!(lock).unwrap();
@@ -261,9 +273,10 @@ impl SelfProfiler {
261273

262274
pub fn save_results(&self, opts: &Options) {
263275
let category_data = self.data.json();
264-
let compilation_options = format!("{{ \"optimization_level\": \"{:?}\", \"incremental\": {} }}",
265-
opts.optimize,
266-
if opts.incremental.is_some() { "true" } else { "false" });
276+
let compilation_options =
277+
format!("{{ \"optimization_level\": \"{:?}\", \"incremental\": {} }}",
278+
opts.optimize,
279+
if opts.incremental.is_some() { "true" } else { "false" });
267280

268281
let json = format!("{{ \"category_data\": {}, \"compilation_options\": {} }}",
269282
category_data,

0 commit comments

Comments
 (0)