dump_schedule utility (#300)

## Description

Adds the `dump_schedule` crate which is a simple tool that writes
valence's schedule graph to a file named ~~`graph.gv`~~ `graph.svg`.

## Test Plan

Steps:
1. `cargo r -p dump_schedule`
2. Paste the contents of `graph.gv` to https://edotor.net/
3. Look at the pretty graph.
This commit is contained in:
Ryan Johnson 2023-03-23 01:01:50 -07:00 committed by GitHub
parent 628a0ff3c3
commit 1aae22ca3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 16 deletions

2
.gitignore vendored
View file

@ -15,4 +15,4 @@ rust-mc-bot
flamegraph*.svg flamegraph*.svg
perf.data perf.data
perf.data.old perf.data.old
/graph.gv /graph.svg

View file

@ -0,0 +1,8 @@
[package]
name = "dump_schedule"
version = "0.1.0"
edition = "2021"
[dependencies]
bevy_mod_debugdump = "0.7.0"
valence = { path = "../valence", version = "0.2.0" }

View file

@ -0,0 +1,7 @@
# dump_schedule
A simple debugging utility for visualizing Valence's main schedule graph. Generates a SVG file.
1. Ensure that [Graphviz](https://graphviz.org/) is installed and the `dot` command is available.
2. Run the program with `cargo r -p dump_schedule`
3. Open the generated `graph.svg` in your browser or other program, e.g. `chromium graph.svg`.

View file

@ -0,0 +1,36 @@
use std::io;
use std::io::Write;
use std::process::{Command, Stdio};
use valence::bevy_app::prelude::*;
use valence::config::ServerPlugin;
fn main() -> io::Result<()> {
let mut app = App::new();
app.add_plugin(ServerPlugin::new(()));
let dot_graph = bevy_mod_debugdump::schedule_graph_dot(
&mut app,
CoreSchedule::Main,
&bevy_mod_debugdump::schedule_graph::Settings {
ambiguity_enable: false,
..Default::default()
},
);
let mut child = Command::new("dot")
.stdin(Stdio::piped())
.arg("-Tsvg")
.arg("-o")
.arg("graph.svg")
.spawn()?;
if let Some(stdin) = child.stdin.as_mut() {
stdin.write_all(dot_graph.as_bytes())?;
}
child.wait_with_output()?;
Ok(())
}

View file

@ -12,7 +12,6 @@ build = "build/main.rs"
authors = ["Ryan Johnson <ryanj00a@gmail.com>"] authors = ["Ryan Johnson <ryanj00a@gmail.com>"]
[dependencies] [dependencies]
#bevy_mod_debugdump = "0.7.0"
anyhow = "1.0.65" anyhow = "1.0.65"
arrayvec = "0.7.2" arrayvec = "0.7.2"
async-trait = "0.1.60" async-trait = "0.1.60"

View file

@ -339,20 +339,6 @@ pub fn build_plugin(
.add_plugin(PlayerListPlugin) .add_plugin(PlayerListPlugin)
.add_plugin(WeatherPlugin); .add_plugin(WeatherPlugin);
/*
println!(
"{}",
bevy_mod_debugdump::schedule_graph_dot(
app,
CoreSchedule::Main,
&bevy_mod_debugdump::schedule_graph::Settings {
ambiguity_enable: false,
..Default::default()
},
)
);
*/
Ok(()) Ok(())
} }