Add support for generating treemaps

finchie
Apr 29, 2024, 11:32 AM
XVQXXAGZ4WHBQIU3WEUKLZX6FKV5V52LSTTGMFXR42WPWJZJNENQC

Dependencies

  • [2] PVUQYWZE Live-reload generated site using Trunk
  • [3] ZEN3WUPD Add support for histogram charts
  • [4] 7CVIL7UJ Create simple metadata parser
  • [5] Q3Z6XMP5 Migrate dependency tree to `petgraph::Graph`
  • [6] T34OV3YQ Store timings output in `timings::Output` struct
  • [7] V2NPEIA6 Use custom types to deserialize `--timings=json` output
  • [8] C43IWI7G Move visualization logic into separate module
  • [9] B2L26LOA Store index of dependency nodes
  • [10] LOR3KOXG Parse JSON output from `cargo build --timings`
  • [11] UQJO24KB Use `forceatlas2` to construct graph layout
  • [12] ZPFD3275 Switch from `cargo_metadata`+`petgraph` to `guppy`
  • [13] JVYWRCPT Add basic chart visualisation
  • [14] YA5ITLOV Add support for Sankey diagrams
  • [*] OPTMCUTB Use timings `duration` to set size of rendered node

Change contents

  • replacement in src/visualize/mod.rs at line 3
    [4.76][3.0:70]()
    use charming::series::{Bar, Graph, GraphLayoutForce, Sankey, Series};
    [4.76]
    [4.1302]
    use charming::element::{ColorBy, ItemStyle, Label};
    use charming::series::{Bar, Graph, GraphLayoutForce, Sankey, Series, Treemap};
  • edit in src/visualize/mod.rs at line 11
    [4.1352]
    [4.215]
    mod treemap;
  • edit in src/visualize/mod.rs at line 18
    [3.102]
    [4.274]
    Treemap,
  • edit in src/visualize/mod.rs at line 46
    [3.531]
    [4.915]
    Style::Treemap => {
    Treemap::new()
    .data(treemap::data(graph, timings))
    .item_style(ItemStyle::new().border_width(5).gap_width(1))
    .visible_min(300_u64)
    .upper_label(Label::new().show(true))
    .color(treemap::color())
    // TODO: this is a hack that sets the levels to be a complete worst-case
    .levels(treemap::levels(timings.pkg_times().count()))
    .color_by(ColorBy::Series)
    .into()
    }
  • replacement in src/timings.rs at line 25
    [4.571][4.571:583]()
    enum Mode {
    [4.571]
    [4.583]
    pub enum Mode {
  • replacement in src/timings.rs at line 37
    [4.991][4.991:1009]()
    enum TargetKind {
    [4.991]
    [4.1009]
    pub enum TargetKind {
  • replacement in src/timings.rs at line 54
    [4.1311][4.1311:1471]()
    struct Target {
    kind: Vec<TargetKind>,
    name: String,
    src_path: Utf8PathBuf,
    edition: Edition,
    doc: bool,
    doctest: bool,
    test: bool,
    [4.1311]
    [4.1471]
    pub struct Target {
    pub kind: Vec<TargetKind>,
    pub name: String,
    pub src_path: Utf8PathBuf,
    pub edition: Edition,
    pub doc: bool,
    pub doctest: bool,
    pub test: bool,
  • replacement in src/timings.rs at line 68
    [4.752][4.84:101]()
    struct Message {
    [4.752]
    [4.1607]
    pub struct Message {
  • replacement in src/timings.rs at line 70
    [4.1627][4.102:145](),[4.145][4.820:904](),[4.820][4.820:904]()
    package_id: cargo_metadata::PackageId,
    target: Target,
    mode: Mode,
    duration: f64,
    rmeta_time: Option<f64>,
    [4.1627]
    [4.904]
    pub package_id: cargo_metadata::PackageId,
    pub target: Target,
    pub mode: Mode,
    pub duration: f64,
    pub rmeta_time: Option<f64>,
  • edit in src/timings.rs at line 149
    [16.181]
    [3.3272]
    }
    pub fn pkg_messages(&self, pkg: &PackageId) -> Option<&Vec<Message>> {
    self.repr.get(pkg)
  • edit in src/timings.rs at line 162
    [4.2695]
    [4.2708]
    pub fn len(&self) -> usize {
    self.repr.len()
    }
  • replacement in src/main.rs at line 14
    [4.897][3.3633:3714]()
    visualize::for_style(visualize::Style::Histogram, &package_graph, &timings);
    [4.897]
    [4.924]
    visualize::for_style(visualize::Style::Treemap, &package_graph, &timings);
  • replacement in Trunk.toml at line 21
    [2.728][2.728:745]()
    watch = ["src/"]
    [2.728]
    [2.745]
    watch = ["src/", "Cargo.toml"]
  • replacement in Cargo.toml at line 8
    [4.2916][4.1637:1656](),[4.1066][4.1637:1656]()
    charming = "0.3.1"
    [4.2916]
    [4.1747]
    charming = { path = "../charming/charming" }
  • edit in Cargo.lock at line 96
    [4.2118][4.2118:2261]()
    source = "registry+https://github.com/rust-lang/crates.io-index"
    checksum = "f4c6b6990238a64b4ae139e7085ce2a11815cb67a0c066a3333ce40f3a329be3"