[self-profiler] Misc cleanups
This commit is contained in:
parent
8170828cb9
commit
e9ebc2e956
@ -69,12 +69,7 @@ fn new() -> CategoryResultData {
|
||||
}
|
||||
|
||||
fn total_time(&self) -> u64 {
|
||||
let mut total = 0;
|
||||
for (_, time) in &self.query_times {
|
||||
total += time;
|
||||
}
|
||||
|
||||
total
|
||||
self.query_times.iter().map(|(_, time)| time).sum()
|
||||
}
|
||||
|
||||
fn total_cache_data(&self) -> (u64, u64) {
|
||||
@ -133,13 +128,7 @@ fn consolidate(mut cr1: CalculatedResults, cr2: CalculatedResults) -> Calculated
|
||||
}
|
||||
|
||||
fn total_time(&self) -> u64 {
|
||||
let mut total = 0;
|
||||
|
||||
for (_, data) in &self.categories {
|
||||
total += data.total_time();
|
||||
}
|
||||
|
||||
total
|
||||
self.categories.iter().map(|(_, data)| data.total_time()).sum()
|
||||
}
|
||||
|
||||
fn with_options(mut self, opts: &Options) -> CalculatedResults {
|
||||
@ -411,9 +400,9 @@ pub fn print_results(&mut self, opts: &Options) {
|
||||
.unwrap();
|
||||
|
||||
let mut categories: Vec<_> = results.categories.iter().collect();
|
||||
categories.sort_by(|(_, data1), (_, data2)| data2.total_time().cmp(&data1.total_time()));
|
||||
categories.sort_by_cached_key(|(_, d)| d.total_time());
|
||||
|
||||
for (category, data) in categories {
|
||||
for (category, data) in categories.iter().rev() {
|
||||
let (category_hits, category_total) = data.total_cache_data();
|
||||
let category_hit_percent = calculate_percent(category_hits, category_total);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user