Skip to content

Commit

Permalink
Merge pull request #14 from epage/profile
Browse files Browse the repository at this point in the history
Smooth out profiling process
  • Loading branch information
epage authored Sep 29, 2021
2 parents b291ba3 + f71219d commit a5bdf63
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ harness = false
[[bench]]
name = "access"
harness = false

[profile.release]
debug = 1
17 changes: 17 additions & 0 deletions examples/bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
fn main() {
let mut args = std::env::args();
let _ = args.next();
let method = args.next().unwrap_or_else(|| String::from("from_ref"));
let sample = args.next().unwrap_or_else(|| String::from("0123456789"));
let count = args
.next()
.unwrap_or_else(|| String::from("10000000"))
.parse::<usize>()
.unwrap();
let method = match method.as_str() {
"from_ref" => |s| kstring::KString::from_ref(s),
"from_string" => |s| kstring::KString::from_string(String::from(s)),
_ => panic!("{:?} unsupported, try `from_ref`, `from_string`", method),
};
(0..count).map(|_| method(&sample)).last();
}

0 comments on commit a5bdf63

Please sign in to comment.