Skip to content

Commit 5914cde

Browse files
committed
chore: fold without costs
1 parent 80a542a commit 5914cde

11 files changed

Lines changed: 165 additions & 157 deletions

callgrind-utils/src/flamegraph.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ const MIN_BUDGET: f64 = 1.0;
1313
const MIN_BUDGET_FRACTION: f64 = 0.0005;
1414

1515
impl CallGraph {
16+
pub fn to_folded_without_costs(&self) -> Vec<String> {
17+
self.to_folded().iter().map(|line| {
18+
let mut parts = line.split_whitespace();
19+
let stack = parts.next().unwrap_or_default();
20+
format!("{stack} <cost>")
21+
}).collect()
22+
}
23+
1624
pub fn to_folded(&self) -> Vec<String> {
1725
let graph = self.inner.graph.borrow();
1826
let indices: Vec<NodeIndex> = graph.node_indices().collect();
@@ -177,7 +185,7 @@ fn fold_dfs(
177185
stack.pop();
178186
}
179187

180-
fn fold_line(stack: &[usize], names: &[&str], count: u64) -> String {
188+
fn fold_line(stack: &[usize], names: &[&str], _count: u64) -> String {
181189
let mut line = String::new();
182190
for (i, &idx) in stack.iter().enumerate() {
183191
if i > 0 {
@@ -186,6 +194,6 @@ fn fold_line(stack: &[usize], names: &[&str], count: u64) -> String {
186194
line.push_str(names[idx]);
187195
}
188196
line.push(' ');
189-
line.push_str(&count.to_string());
197+
line.push('1');
190198
line
191199
}

callgrind-utils/tests/snapshot.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ fn fixture_canonical_json(#[case] stem: &str) {
121121
graph
122122
.to_flamegraph_file(format!("{stem}.partial.svg"))
123123
.unwrap();
124-
insta::assert_snapshot!(format!("{stem}_folded"), graph.to_folded().join("\n"));
124+
insta::assert_snapshot!(format!("{stem}_folded"), graph.to_folded_without_costs().join("\n"));
125125

126126
let json = graph.to_json().expect("to_json");
127127

@@ -152,7 +152,7 @@ fn fixture_full_trace(#[case] stem: &str) {
152152
.to_flamegraph_file(format!("{stem}.full.svg"))
153153
.unwrap();
154154

155-
insta::assert_snapshot!(format!("{stem}_full_folded"), graph.to_folded().join("\n"));
155+
insta::assert_snapshot!(format!("{stem}_full_folded"), graph.to_folded_without_costs().join("\n"));
156156

157157
let json = graph.redact().to_json().expect("to_json");
158158
insta::assert_snapshot!(format!("{stem}_full__json"), json);
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
source: tests/snapshot.rs
3-
expression: "graph.to_folded().join(\"\\n\")"
3+
expression: "graph.to_folded_without_costs().join(\"\\n\")"
44
---
5-
main 18
6-
main;a 10
7-
main;a;b 10
8-
main;a;b;c 7
5+
main <cost>
6+
main;a <cost>
7+
main;a;b <cost>
8+
main;a;b;c <cost>
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
source: tests/snapshot.rs
3-
expression: "graph.to_folded().join(\"\\n\")"
3+
expression: "graph.to_folded_without_costs().join(\"\\n\")"
44
---
5-
main 18
6-
main;a 10
7-
main;a;b 10
8-
main;a;b;c 7
5+
main <cost>
6+
main;a <cost>
7+
main;a;b <cost>
8+
main;a;b;c <cost>
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
source: tests/snapshot.rs
3-
expression: "graph.to_folded().join(\"\\n\")"
3+
expression: "graph.to_folded_without_costs().join(\"\\n\")"
44
---
5-
main 18
6-
main;top 16
7-
main;top;left 10
8-
main;top;left;bottom 7
9-
main;top;right 10
10-
main;top;right;bottom 7
5+
main <cost>
6+
main;top <cost>
7+
main;top;left <cost>
8+
main;top;left;bottom <cost>
9+
main;top;right <cost>
10+
main;top;right;bottom <cost>
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
source: tests/snapshot.rs
3-
expression: "graph.to_folded().join(\"\\n\")"
3+
expression: "graph.to_folded_without_costs().join(\"\\n\")"
44
---
5-
main 18
6-
main;top 16
7-
main;top;left 10
8-
main;top;left;bottom 7
9-
main;top;right 10
10-
main;top;right;bottom 7
5+
main <cost>
6+
main;top <cost>
7+
main;top;left <cost>
8+
main;top;left;bottom <cost>
9+
main;top;right <cost>
10+
main;top;right;bottom <cost>
Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
---
22
source: tests/snapshot.rs
3-
expression: "graph.to_folded().join(\"\\n\")"
3+
expression: "graph.to_folded_without_costs().join(\"\\n\")"
44
---
5-
run_measured 17
6-
run_measured;complex_fractal_benchmark 217
7-
run_measured;complex_fractal_benchmark;build_fractal 92
8-
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2 5317
9-
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2;pool_alloc 2670
10-
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2;compute_child_value 4259
11-
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2;build_fractal'2 73824
12-
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2;compute_tree_hash 3694
13-
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2;compute_tree_hash;compute_tree_hash'2 6357
14-
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2;compute_tree_hash;compute_tree_hash'2;compute_tree_hash'2 12406
15-
run_measured;complex_fractal_benchmark;build_fractal;compute_tree_hash 2811
16-
run_measured;complex_fractal_benchmark;build_fractal;compute_tree_hash;compute_tree_hash'2 4838
17-
run_measured;complex_fractal_benchmark;build_fractal;compute_tree_hash;compute_tree_hash'2;compute_tree_hash'2 9440
18-
run_measured;complex_fractal_benchmark;analyze_fractal_tree 86
19-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;recursive_sum 56
20-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;recursive_sum;recursive_sum'2 2645
21-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;recursive_sum;recursive_sum'2;recursive_sum'2 8206
22-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;count_nodes 53
23-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;count_nodes;count_nodes'2 2407
24-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;count_nodes;count_nodes'2;count_nodes'2 7355
25-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;max_path_sum 71
26-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;max_path_sum;max_path_sum'2 3014
27-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;max_path_sum;max_path_sum'2;max_path_sum'2 8851
28-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;collect_leaves 52
29-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;collect_leaves;collect_leaves'2 2559
30-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;collect_leaves;collect_leaves'2;collect_leaves'2 8055
31-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;compute_variance 6349
32-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2 97
33-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;recursive_sum 75
34-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;recursive_sum;recursive_sum'2 3527
35-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;recursive_sum;recursive_sum'2;recursive_sum'2 10942
36-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;count_nodes 71
37-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;count_nodes;count_nodes'2 3210
38-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;count_nodes;count_nodes'2;count_nodes'2 9807
39-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;max_path_sum 95
40-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;max_path_sum;max_path_sum'2 4019
41-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;max_path_sum;max_path_sum'2;max_path_sum'2 11802
42-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;collect_leaves 69
43-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;collect_leaves;collect_leaves'2 3412
44-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;collect_leaves;collect_leaves'2;collect_leaves'2 10741
45-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;compute_variance 8466
46-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;analyze_fractal_tree'2 33290
47-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;compute_complexity_score 21
48-
run_measured;complex_fractal_benchmark;analyze_fractal_tree;compute_complexity_score;recursive_path_score 33
49-
run_measured;complex_fractal_benchmark;fibonacci_memo 42
50-
run_measured;complex_fractal_benchmark;fibonacci_memo;fibonacci_memo'2 128
51-
run_measured;complex_fractal_benchmark;fibonacci_memo;fibonacci_memo'2;fibonacci_memo'2 1376
52-
run_measured;complex_fractal_benchmark;fibonacci_memo;fibonacci_memo'2;fibonacci_memo'2 46
53-
run_measured;complex_fractal_benchmark;compute_tree_hash 2811
54-
run_measured;complex_fractal_benchmark;compute_tree_hash;compute_tree_hash'2 4838
55-
run_measured;complex_fractal_benchmark;compute_tree_hash;compute_tree_hash'2;compute_tree_hash'2 9440
5+
run_measured <cost>
6+
run_measured;complex_fractal_benchmark <cost>
7+
run_measured;complex_fractal_benchmark;build_fractal <cost>
8+
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2 <cost>
9+
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2;pool_alloc <cost>
10+
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2;compute_child_value <cost>
11+
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2;build_fractal'2 <cost>
12+
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2;compute_tree_hash <cost>
13+
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2;compute_tree_hash;compute_tree_hash'2 <cost>
14+
run_measured;complex_fractal_benchmark;build_fractal;build_fractal'2;compute_tree_hash;compute_tree_hash'2;compute_tree_hash'2 <cost>
15+
run_measured;complex_fractal_benchmark;build_fractal;compute_tree_hash <cost>
16+
run_measured;complex_fractal_benchmark;build_fractal;compute_tree_hash;compute_tree_hash'2 <cost>
17+
run_measured;complex_fractal_benchmark;build_fractal;compute_tree_hash;compute_tree_hash'2;compute_tree_hash'2 <cost>
18+
run_measured;complex_fractal_benchmark;analyze_fractal_tree <cost>
19+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;recursive_sum <cost>
20+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;recursive_sum;recursive_sum'2 <cost>
21+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;recursive_sum;recursive_sum'2;recursive_sum'2 <cost>
22+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;count_nodes <cost>
23+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;count_nodes;count_nodes'2 <cost>
24+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;count_nodes;count_nodes'2;count_nodes'2 <cost>
25+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;max_path_sum <cost>
26+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;max_path_sum;max_path_sum'2 <cost>
27+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;max_path_sum;max_path_sum'2;max_path_sum'2 <cost>
28+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;collect_leaves <cost>
29+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;collect_leaves;collect_leaves'2 <cost>
30+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;collect_leaves;collect_leaves'2;collect_leaves'2 <cost>
31+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;compute_variance <cost>
32+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2 <cost>
33+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;recursive_sum <cost>
34+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;recursive_sum;recursive_sum'2 <cost>
35+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;recursive_sum;recursive_sum'2;recursive_sum'2 <cost>
36+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;count_nodes <cost>
37+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;count_nodes;count_nodes'2 <cost>
38+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;count_nodes;count_nodes'2;count_nodes'2 <cost>
39+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;max_path_sum <cost>
40+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;max_path_sum;max_path_sum'2 <cost>
41+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;max_path_sum;max_path_sum'2;max_path_sum'2 <cost>
42+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;collect_leaves <cost>
43+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;collect_leaves;collect_leaves'2 <cost>
44+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;collect_leaves;collect_leaves'2;collect_leaves'2 <cost>
45+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;compute_variance <cost>
46+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;analyze_fractal_tree'2;analyze_fractal_tree'2 <cost>
47+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;compute_complexity_score <cost>
48+
run_measured;complex_fractal_benchmark;analyze_fractal_tree;compute_complexity_score;recursive_path_score <cost>
49+
run_measured;complex_fractal_benchmark;fibonacci_memo <cost>
50+
run_measured;complex_fractal_benchmark;fibonacci_memo;fibonacci_memo'2 <cost>
51+
run_measured;complex_fractal_benchmark;fibonacci_memo;fibonacci_memo'2;fibonacci_memo'2 <cost>
52+
run_measured;complex_fractal_benchmark;fibonacci_memo;fibonacci_memo'2;fibonacci_memo'2 <cost>
53+
run_measured;complex_fractal_benchmark;compute_tree_hash <cost>
54+
run_measured;complex_fractal_benchmark;compute_tree_hash;compute_tree_hash'2 <cost>
55+
run_measured;complex_fractal_benchmark;compute_tree_hash;compute_tree_hash'2;compute_tree_hash'2 <cost>

0 commit comments

Comments
 (0)