Skip to content

Commit 58b2c44

Browse files
committed
Add --breakdown flag and fix SDE
1 parent e15fbe6 commit 58b2c44

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

benchmarking-tool/main.rs

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ fn main() {
3131
input.format,
3232
input.sort,
3333
input.limit,
34+
input.breakdown,
3435
),
3536
_ => todo!(),
3637
}
@@ -56,6 +57,7 @@ fn main() {
5657
input.format,
5758
input.sort,
5859
input.limit,
60+
input.breakdown,
5961
),
6062
_ => todo!(),
6163
}
@@ -96,6 +98,8 @@ pub struct BenchmarkInput {
9698
pub keep: Option<String>,
9799
/// skip Rust internals
98100
pub skip_internals: bool,
101+
/// include all inst
102+
pub breakdown: bool,
99103
}
100104

101105
impl BenchmarkInput {
@@ -112,6 +116,7 @@ impl BenchmarkInput {
112116
// ...
113117
keep: None,
114118
skip_internals: true,
119+
breakdown: false,
115120
};
116121

117122
let mut left_over: Option<String> = None;
@@ -159,6 +164,9 @@ impl BenchmarkInput {
159164
"--all" => {
160165
this.skip_internals = false;
161166
}
167+
"--breakdown" => {
168+
this.breakdown = true;
169+
}
162170
"--arg" => {
163171
let next = args.next().unwrap();
164172
let (name, values) = next.split_once('=').unwrap();
@@ -187,6 +195,7 @@ pub fn print_results(
187195
output_format: OutputFormat,
188196
sorting: Option<utilities::Sorting>,
189197
limit: usize,
198+
breakdown: bool,
190199
) {
191200
use std::borrow::Cow;
192201
use utilities::count_with_seperator;
@@ -268,11 +277,13 @@ pub fn print_results(
268277
" total: {count}",
269278
count = count_with_seperator(row.total as usize)
270279
);
271-
for (name, count) in &row.entries {
272-
print!(
273-
" {name}: {count}",
274-
count = count_with_seperator(*count as usize)
275-
);
280+
if breakdown {
281+
for (name, count) in &row.entries {
282+
print!(
283+
" {name}: {count}",
284+
count = count_with_seperator(*count as usize)
285+
);
286+
}
276287
}
277288
println!();
278289
}
@@ -283,11 +294,18 @@ pub fn print_results(
283294
if buf.len() > 1 {
284295
buf.push(',');
285296
}
286-
buf.push_str(&json_builder_macro::json! {
287-
symbol_name: row.symbol_name.as_str(),
288-
total: row.total,
289-
kinds: row.entries
290-
});
297+
if breakdown {
298+
buf.push_str(&json_builder_macro::json! {
299+
symbol_name: row.symbol_name.as_str(),
300+
total: row.total,
301+
kinds: row.entries
302+
});
303+
} else {
304+
buf.push_str(&json_builder_macro::json! {
305+
symbol_name: row.symbol_name.as_str(),
306+
total: row.total
307+
});
308+
}
291309
}
292310
buf.push(']');
293311
println!("{buf}");

benchmarking-tool/tools/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ pub mod wall_clock;
44
#[cfg(target_family = "unix")]
55
pub mod perf_events;
66

7-
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
7+
#[cfg(any(target_arch = "x86", target_arch = "x86_64", debug_assertions))]
88
pub mod sde;

benchmarking-tool/tools/sde.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub fn run_sde(
77
request: crate::CommandRequest,
88
options: crate::ToolOptions,
99
) -> Result<crate::ToolOutput, ()> {
10-
let file_path: &str = options.as_deref().unwrap_or(TEMP_FILE);
10+
let file_path: &str = options.keep.as_deref().unwrap_or(TEMP_FILE);
1111

1212
// TODO hmm
1313
let blocks = 50;
@@ -39,8 +39,8 @@ pub fn run_sde(
3939

4040
let symbols: Vec<_> = rows
4141
.into_iter()
42-
.map(|(name, item)| crate::Entry {
43-
name,
42+
.map(|(symbol_name, item)| crate::Entry {
43+
symbol_name,
4444
total: item.total,
4545
entries: vec![
4646
("mem_read".to_owned(), item.mem_read),
@@ -52,9 +52,9 @@ pub fn run_sde(
5252
})
5353
.collect();
5454

55-
let total: usize = rows.iter().fold(0, |acc, row| acc + row.total as usize);
55+
let total = symbols.iter().fold(0, |acc, row| acc + row.total);
5656

57-
if input.keep.is_none() {
57+
if options.keep.is_none() {
5858
std::fs::remove_file(file_path).unwrap();
5959
}
6060

0 commit comments

Comments
 (0)