aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml4
-rw-r--r--src/irq.rs1
-rw-r--r--src/perfcnt/intel/counters.rs6
-rw-r--r--src/perfcnt/mod.rs11
4 files changed, 18 insertions, 4 deletions
diff --git a/Cargo.toml b/Cargo.toml
index fdf0694..c8066f2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,9 +12,11 @@ documentation = "http://gz.github.io/rust-x86/x86/"
readme = "README.md"
keywords = ["ia32", "os", "amd64", "x86", "x86-64"]
license = "MIT"
-
build = "build.rs"
+[features]
+cached_counters = []
+
[[test]]
name = "no_std_build"
harness = false
diff --git a/src/irq.rs b/src/irq.rs
index ab1ae7c..50732d2 100644
--- a/src/irq.rs
+++ b/src/irq.rs
@@ -179,7 +179,6 @@ impl fmt::Debug for PageFaultError {
#[test]
fn bit_macro() {
-
assert!(PFAULT_ERROR_PK.bits() == 0b100000);
assert!(PFAULT_ERROR_ID.bits() == 0b10000);
assert!(PFAULT_ERROR_RSVD.bits() == 0b1000);
diff --git a/src/perfcnt/intel/counters.rs b/src/perfcnt/intel/counters.rs
index d05fd5c..9d046bf 100644
--- a/src/perfcnt/intel/counters.rs
+++ b/src/perfcnt/intel/counters.rs
@@ -5,4 +5,8 @@ use super::description::PebsType;
use super::description::Tuple;
use super::description::MSRIndex;
-include!(concat!(env!("OUT_DIR"), "/counters.rs")); \ No newline at end of file
+#[cfg(not(feature = "cached_counters"))]
+include!(concat!(env!("OUT_DIR"), "/counters.rs"));
+
+#[cfg(feature = "cached_counters")]
+include!("generated.rs");
diff --git a/src/perfcnt/mod.rs b/src/perfcnt/mod.rs
index 79e536c..fba94bd 100644
--- a/src/perfcnt/mod.rs
+++ b/src/perfcnt/mod.rs
@@ -6,7 +6,7 @@ use core::str;
pub mod intel;
-const MODEL_LEN: usize = 20;
+const MODEL_LEN: usize = 30;
#[derive(Default)]
struct ModelWriter {
@@ -64,3 +64,12 @@ pub fn core_counters() -> Option<&'static phf::Map<&'static str, intel::descript
pub fn uncore_counters() -> Option<&'static phf::Map<&'static str, intel::description::IntelPerformanceCounterDescription>> {
get_counters!("{}-{}-{:X}{:X}-uncore")
}
+
+#[test]
+fn counter_test() {
+ core_counters().map(|cc| {
+ cc.get("INST_RETIRED.ANY").map(|p| {
+ assert!(p.event_name == "INST_RETIRED.ANY");
+ });
+ });
+} \ No newline at end of file