Skip to content

Commit

Permalink
Add perfmon to Stats
Browse files Browse the repository at this point in the history
  • Loading branch information
caizixian committed May 18, 2021
1 parent e4d5b4f commit ce0c3f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ atomic-traits = "0.2.0"
atomic = "0.4.6"
spin = "0.5.2"
env_logger = "0.8.2"
pfm = "0.0.3"

[dev-dependencies]
crossbeam = "0.7.3"
Expand Down
5 changes: 5 additions & 0 deletions src/util/statistics/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::Arc;
use std::sync::Mutex;
use pfm::Perfmon;

pub const MAX_PHASES: usize = 1 << 12;
pub const MAX_COUNTERS: usize = 100;
Expand Down Expand Up @@ -37,6 +38,7 @@ impl SharedStats {
pub struct Stats {
gc_count: AtomicUsize,
total_time: Arc<Mutex<Timer>>,
perfmon: Perfmon,

pub shared: Arc<SharedStats>,
counters: Mutex<Vec<Arc<Mutex<dyn Counter + Send>>>>,
Expand All @@ -55,9 +57,12 @@ impl Stats {
true,
false,
)));
let mut perfmon: Perfmon = Default::default();
perfmon.initialize().expect("Perfmon failed to initialize");
Stats {
gc_count: AtomicUsize::new(0),
total_time: t.clone(),
perfmon,

shared,
counters: Mutex::new(vec![t]),
Expand Down

0 comments on commit ce0c3f9

Please sign in to comment.