Skip to content

Commit b372562

Browse files
committed
align flame charts to close #1
1 parent 8f8579a commit b372562

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

R/flame.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ print_flame_tree <- function(tree, width, min_pct, total_samples, max_depth) {
110110

111111
bar_width <- max(1, round(width * item$samples / total_samples))
112112
bar <- strrep("=", bar_width)
113+
padding <- strrep(" ", width - bar_width)
113114
indent <- strrep(" ", item$depth)
114115

115116
name <- truncate_string(item$name, 40)
116-
cat(sprintf("%s[%s] %s (%.1f%%)\n", indent, bar, name, pct))
117+
cat(sprintf("[%s%s]%s %s (%.1f%%)\n", bar, padding, indent, name, pct))
117118
}
118119
}
119120
}

tests/testthat/_snaps/flame.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
Total time: 50 ms | Width: 70 chars | Min: 2%
1111
1212
[======================================================================] (root) 100%
13-
[======================================================================] outer (100.0%)
14-
[==========================================] inner (60.0%)
15-
[==============] helper (20.0%)
16-
[============================] deep (40.0%)
13+
[======================================================================] outer (100.0%)
14+
[========================================== ] inner (60.0%)
15+
[============== ] helper (20.0%)
16+
[============================ ] deep (40.0%)
1717
1818
Legend: [====] = time spent, width proportional to time
1919

@@ -29,10 +29,10 @@
2929
Total time: 50 ms | Width: 40 chars | Min: 2%
3030
3131
[========================================] (root) 100%
32-
[========================================] outer (100.0%)
33-
[========================] inner (60.0%)
34-
[========] helper (20.0%)
35-
[================] deep (40.0%)
32+
[========================================] outer (100.0%)
33+
[======================== ] inner (60.0%)
34+
[======== ] helper (20.0%)
35+
[================ ] deep (40.0%)
3636
3737
Legend: [====] = time spent, width proportional to time
3838

@@ -48,9 +48,9 @@
4848
Total time: 50 ms | Width: 70 chars | Min: 30%
4949
5050
[======================================================================] (root) 100%
51-
[======================================================================] outer (100.0%)
52-
[==========================================] inner (60.0%)
53-
[============================] deep (40.0%)
51+
[======================================================================] outer (100.0%)
52+
[========================================== ] inner (60.0%)
53+
[============================ ] deep (40.0%)
5454
5555
Legend: [====] = time spent, width proportional to time
5656

0 commit comments

Comments
 (0)