-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
346 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
extern crate perfcnt; | ||
extern crate x86; | ||
|
||
use perfcnt::{PerfCounter, AbstractPerfCounter}; | ||
use perfcnt::linux::{PerfCounterBuilderLinux}; | ||
use perfcnt::linux::PerfCounterBuilderLinux; | ||
use perfcnt::{AbstractPerfCounter, PerfCounter}; | ||
|
||
pub fn main() { | ||
let counter_description = x86::perfcnt::intel::events().unwrap().get("BR_INST_RETIRED.ALL_BRANCHES").unwrap(); | ||
let mut pc: PerfCounter = PerfCounterBuilderLinux::from_intel_event_description(counter_description) | ||
.exclude_idle() | ||
.exclude_kernel() | ||
.finish() | ||
.expect("Could not create counter"); | ||
let counter_description = x86::perfcnt::intel::events() | ||
.unwrap() | ||
.get("BR_INST_RETIRED.ALL_BRANCHES") | ||
.unwrap(); | ||
let mut pc: PerfCounter = | ||
PerfCounterBuilderLinux::from_intel_event_description(counter_description) | ||
.exclude_idle() | ||
.exclude_kernel() | ||
.finish() | ||
.expect("Could not create counter"); | ||
|
||
pc.start().expect("Can not start the counter"); | ||
println!(""); | ||
pc.stop().expect("Can not stop the counter");; | ||
pc.stop().expect("Can not stop the counter"); | ||
|
||
println!("{}: {:?}", counter_description.brief_description, pc.read().expect("Can not read counter")); | ||
println!( | ||
"{}: {:?}", | ||
counter_description.brief_description, | ||
pc.read().expect("Can not read counter") | ||
); | ||
pc.reset().expect("Can not reset the counter"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.