Using perf:
$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg
NOTE: See @GabrielMajeri's comments below about the
-g
option.
#![feature(unboxed_closures)] | |
#![feature(core)] | |
#![feature(io)] | |
use std::old_io::stdio::{stdin}; | |
use std::collections::HashMap; | |
// This is our toy state example. | |
#[derive(Debug)] | |
struct State { |
#![feature(core_intrinsics)] | |
pub trait Deserialize: Sized { | |
fn deserialize(String) -> Self; | |
} | |
struct Position(i32, i32); | |
struct Velocity(i32, i32); | |
impl Deserialize for Position { |
/// Problem: there is a lot of duplication in function implementations. | |
/// The two types should have the same interface but use a different underlying type. | |
/// | |
/// How can I reduce the amount of duplication and avoid having to update the code in two places? | |
/// In other languages, I would define a base class which accepts a generic type for the `SoundSource`s | |
/// but I don't know how to solve this sort of problem in Rust. | |
struct Sound { | |
// Shared properties | |
is_playing: bool, |
Using perf:
$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg
NOTE: See @GabrielMajeri's comments below about the
-g
option.