mirror of
https://github.com/plasma-umass/coz.git
synced 2024-09-11 04:55:25 +03:00
After seeing a recording of Emery's recent talk at Strange Loop I was super impressed with `coz` and immediately wanted to try it out with Rust code! I was curious to see if `coz` could help us out with profiling either Cargo, Rust's build system, or perhaps the compiler itself, `rustc`. In any case I ended up creating https://github.com/alexcrichton/coz-rs as a repository to house an implementation of `coz.h` for Rust so `coz` could be used to easily work with Rust executables. I toyed around a bit and Emery [mentioned] that this would be good support to have upstream once it's working, and I think it's working now! I haven't been able to get a ton of useful results myself yet, but I'm still figuring out the best way to ask `coz` questions and the best way to instrument programs myself. Nonetheless I think that the Rust support here is correct in the sense that it's a faithful translation of `coz.h`, and now it's just a problem with me learning how best to instrument programs. This commit adds a new `rust` directory with a crate (Rust parlance for "library") which provides macros that allow using `coz` instrumentation similar as you would in C, except in idiomatic Rust style. I've published the crate on Rust's package registry, crates.io, as [`coz`][crate], and I don't mind keeping it there or transferring it to y'all, whichever you'd prefer! I also don't mind being on the hook for reviewing any Rust-related changes, or if y'all need to jettison the Rust support in the future I don't mind that either and can give it a home! [mentioned]: https://github.com/alexcrichton/coz-rs/issues/2 [crate]: https://crates.io/crates/coz
16 lines
233 B
Rust
16 lines
233 B
Rust
#[test]
|
|
fn smoke() {
|
|
coz::progress!();
|
|
coz::progress!("foo");
|
|
coz::begin!("foo");
|
|
coz::end!("foo");
|
|
}
|
|
|
|
#[test]
|
|
fn smoke_scoped() {
|
|
coz::scope!("scope");
|
|
let mut x = 1u32;
|
|
x = x + 1;
|
|
assert!(x == 2);
|
|
}
|