Skip to main content

stperf/
format.rs

1//! Formats for making the formatted outputs (see
2//! [`get_formatted_string`](../fn.get_formatted_string.html))
3
4/// A very streamlined format. This is the default format.
5///
6/// ```text
7/// ╶──┬╼ main                        - 100.0%, 300 ms/loop
8///    ├──┬╼ physics simulation       -  66.7%, 200 ms/loop
9///    │  ├───╼ moving things         -  50.0%, 100 ms/loop
10///    │  └───╼ resolving collisions  -  50.0%, 100 ms/loop
11///    └───╼ rendering                -  33.3%, 100 ms/loop
12/// ```
13pub static STREAMLINED: FormattingOptions = FormattingOptions {
14    starting_branch: "╶",
15    continuing_branch: "│",
16    branching_branch: "├",
17    turning_branch: "└",
18    ending_branch: "───╼",
19    turning_ending_branch: "──┬╼",
20};
21
22/// Like `STREAMLINED` except with rounded corners.
23///
24/// ```text
25/// ╶──┬╼ main                        - 100.0%, 300 ms/loop
26///    ├──┬╼ physics simulation       -  66.7%, 200 ms/loop
27///    │  ├───╼ moving things         -  50.0%, 100 ms/loop
28///    │  ╰───╼ resolving collisions  -  50.0%, 100 ms/loop
29///    ╰───╼ rendering                -  33.3%, 100 ms/loop
30/// ```
31pub static STREAMLINED_ROUNDED: FormattingOptions = FormattingOptions {
32    starting_branch: "╶",
33    continuing_branch: "│",
34    branching_branch: "├",
35    turning_branch: "╰",
36    ending_branch: "───╼",
37    turning_ending_branch: "──┬╼",
38};
39
40/// A format made out of -'s and |'s. Very compatible with small charsets!
41///
42/// ```text
43/// ----- main                        - 100.0%, 300 ms/loop
44///    |---- physics simulation       -  66.7%, 200 ms/loop
45///    |  |---- moving things         -  50.0%, 100 ms/loop
46///    |  \---- resolving collisions  -  50.0%, 100 ms/loop
47///    \---- rendering                -  33.3%, 100 ms/loop
48/// ```
49pub static COMPATIBLE: FormattingOptions = FormattingOptions {
50    starting_branch: "-",
51    continuing_branch: "|",
52    branching_branch: "|",
53    turning_branch: "\\",
54    ending_branch: "----",
55    turning_ending_branch: "----",
56};
57
58/// This format is for those who like their lines doubled.
59///
60/// ```text
61/// ═══╦═ main                        - 100.0%, 300 ms/loop
62///    ╠══╦═ physics simulation       -  66.7%, 200 ms/loop
63///    ║  ╠════ moving things         -  50.0%, 100 ms/loop
64///    ║  ╚════ resolving collisions  -  50.0%, 100 ms/loop
65///    ╚════ rendering                -  33.3%, 100 ms/loop
66/// ```
67pub static DOUBLED: FormattingOptions = FormattingOptions {
68    starting_branch: "═",
69    continuing_branch: "║",
70    branching_branch: "╠",
71    turning_branch: "╚",
72    ending_branch: "════",
73    turning_ending_branch: "══╦═",
74};
75
76/// This format is for debugging the formatting functionality.
77///
78/// ```text
79/// >,,,, main                        - 100.0%, 300 ms/loop
80///    +,,,, physics simulation       -  66.7%, 200 ms/loop
81///    |  +.... moving things         -  50.0%, 100 ms/loop
82///    |  -.... resolving collisions  -  50.0%, 100 ms/loop
83///    -.... rendering                -  33.3%, 100 ms/loop
84/// ```
85pub static DEBUGGING: FormattingOptions = FormattingOptions {
86    starting_branch: ">",
87    continuing_branch: "|",
88    branching_branch: "+",
89    turning_branch: "-",
90    ending_branch: "....",
91    turning_ending_branch: ",,,,",
92};
93
94/// Defines the parts which are used to print out the formatted
95/// string.
96///
97/// See the [`format`](format/index.html) module for options. You
98/// can make your own, if you can parse the sparse instructions
99/// below.
100///
101/// # Reference print (see Fields)
102/// ```text
103/// >,,,, main                      - 100.0%, 300 ms/loop
104///   +,,,, physics simulation      -  66.7%, 200 ms/loop
105///   | +.... moving things         -  50.0%, 100 ms/loop
106///   | -.... resolving collisions  -  50.0%, 100 ms/loop
107///   -.... rendering               -  33.3%, 100 ms/loop
108/// ```
109#[derive(Clone, Copy)]
110pub struct FormattingOptions {
111    /// See the reference-print, `starting_branch` is represented by ">"
112    pub starting_branch: &'static str,
113    /// See the reference-print, `continuing_branch` is represented by "|"
114    pub continuing_branch: &'static str,
115    /// See the reference-print, `branching_branch` is represented by "+"
116    pub branching_branch: &'static str,
117    /// See the reference-print, `turning_branch` is represented by "-"
118    pub turning_branch: &'static str,
119    /// See the reference-print, `ending_branch` is represented by "...."
120    pub ending_branch: &'static str,
121    /// See the reference-print, `turning_ending_branch` is represented by ",,,,"
122    pub turning_ending_branch: &'static str,
123}