fgviz/
fgviz.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10use askama::Template;
11use mz_build_info::build_info;
12use mz_prof_http::FlamegraphTemplate;
13
14fn main() {
15    let bi = build_info!();
16    let mzfg = std::env::args()
17        .nth(1)
18        .map(|path| {
19            let bytes = std::fs::read(path).expect("Failed to read supplied file");
20            String::from_utf8(bytes).expect("Supplied file was not utf-8")
21        })
22        .unwrap_or_else(|| "".into());
23    let rendered = FlamegraphTemplate {
24        version: &bi.human_version(None),
25        title: "Flamegraph Visualizer",
26        mzfg: &mzfg,
27    }
28    .render()
29    .expect("template rendering cannot fail");
30    print!("{}", rendered);
31}