-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Client::plot_config and relevant types
- Loading branch information
1 parent
0a1ea92
commit 5959411
Showing
5 changed files
with
168 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use rand::Rng; | ||
use std::thread::sleep; | ||
use std::time::Duration; | ||
use tracy_client::{Client, PlotConfiguration, PlotFormat, PlotLineStyle, PlotName}; | ||
|
||
// Plots you know statically can be defined freely like so | ||
const PLOT_PLAYER_COUNT: PlotName = tracy_client::plot_name!("Player Count"); | ||
const PLOT_DISK_SPACE: PlotName = tracy_client::plot_name!("Disk Space"); | ||
|
||
pub fn main() { | ||
let client = Client::start(); | ||
let mut rng = rand::thread_rng(); | ||
|
||
// Anything at runtime needs to be created via PlotName | ||
let bandwidth = PlotName::new_leak("Bandwidth".to_string()); | ||
|
||
// You can configure how plots display, this only needs to be done once | ||
client.plot_config( | ||
PLOT_DISK_SPACE, | ||
PlotConfiguration::default() | ||
.format(PlotFormat::Memory) | ||
.fill(false), | ||
); | ||
client.plot_config( | ||
bandwidth, | ||
PlotConfiguration::default() | ||
.format(PlotFormat::Percentage) | ||
.color(Some(0xFF0000)) | ||
.line_style(PlotLineStyle::Stepped), | ||
); | ||
|
||
for _ in 0..50 { | ||
// You don't need to constantly send a value! | ||
if rng.gen_bool(0.75) { | ||
client.plot(PLOT_PLAYER_COUNT, rng.gen_range(0..10) as f64); | ||
} | ||
|
||
client.plot(PLOT_DISK_SPACE, rng.gen_range(0..1000000) as f64); | ||
client.plot(bandwidth, rng.gen_range(0..100) as f64); | ||
|
||
sleep(Duration::from_millis(20)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters