Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates following hashbrown's inclusion in std #127

Merged
merged 4 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ log = "0.4"
quick-xml = { version = "0.14", default-features = false }
num-format = { version = "0.4", default-features = false }
str_stack = "0.1"
hashbrown = "0.2"
rand = "0.6.5"
structopt = { version = "0.2", optional = true }
env_logger = { version = "0.6.0", optional = true }
rgb = "0.8.13"
lazy_static = "1.3.0"
fnv = "1.0.3"
itoa = "0.4.3"
indexmap = "1.0"

[dev-dependencies]
pretty_assertions = "0.6"
Expand Down
6 changes: 3 additions & 3 deletions src/collapse/dtrace.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::Collapse;
use hashbrown::HashMap;
use fnv::FnvHashMap;
use log::warn;
use std::collections::VecDeque;
use std::io;
Expand All @@ -24,7 +24,7 @@ pub struct Folder {
stack: VecDeque<String>,

/// Number of times each call stack has been seen.
occurrences: HashMap<String, usize>,
occurrences: FnvHashMap<String, usize>,

/// Keep track of stack string size while we consume a stack
stack_str_size: usize,
Expand Down Expand Up @@ -115,7 +115,7 @@ impl From<Options> for Folder {
fn from(opt: Options) -> Self {
Self {
stack: VecDeque::default(),
occurrences: HashMap::with_capacity(512),
occurrences: FnvHashMap::with_capacity_and_hasher(512, fnv::FnvBuildHasher::default()),
cache_inlines: Vec::new(),
opt,
stack_str_size: 0,
Expand Down
6 changes: 3 additions & 3 deletions src/collapse/perf.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::Collapse;
use hashbrown::HashMap;
use fnv::FnvHashMap;
use log::warn;
use std::collections::VecDeque;
use std::io;
Expand Down Expand Up @@ -71,7 +71,7 @@ pub struct Folder {
cache_line: Vec<String>,

/// Number of times each call stack has been seen.
occurrences: HashMap<String, usize>,
occurrences: FnvHashMap<String, usize>,

/// Current comm name.
///
Expand Down Expand Up @@ -160,7 +160,7 @@ impl From<Options> for Folder {
skip_stack: false,
stack: VecDeque::default(),
cache_line: Vec::default(),
occurrences: HashMap::with_capacity(512),
occurrences: FnvHashMap::with_capacity_and_hasher(512, fnv::FnvBuildHasher::default()),
pname: String::new(),
event_filtering: EventFilterState::None,
opt,
Expand Down
4 changes: 2 additions & 2 deletions src/differential/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use hashbrown::HashMap;
use fnv::FnvHashMap as HashMap;
jonhoo marked this conversation as resolved.
Show resolved Hide resolved
use log::warn;
use std::fs::File;
use std::io;
Expand Down Expand Up @@ -46,7 +46,7 @@ where
R2: BufRead,
W: Write,
{
let mut stack_counts = HashMap::new();
let mut stack_counts = HashMap::default();
let total1 = parse_stack_counts(opt, &mut stack_counts, before, true)?;
let total2 = parse_stack_counts(opt, &mut stack_counts, after, false)?;
if opt.normalize && total1 != total2 {
Expand Down
15 changes: 8 additions & 7 deletions src/flamegraph/attrs.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use fnv::FnvHashMap;
use indexmap::map::Entry;
use log::warn;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::fs::File;
use std::io::{self, BufRead, BufReader};
use std::path::PathBuf;

type AttrMap<K, V> = indexmap::IndexMap<K, V, fnv::FnvBuildHasher>;

macro_rules! unwrap_or_continue {
($e:expr) => {{
if let Some(x) = $e {
Expand All @@ -18,7 +19,7 @@ macro_rules! unwrap_or_continue {

/// Provides a way to customize the attributes on the SVG elements for a frame.
#[derive(PartialEq, Eq, Debug, Default)]
pub struct FuncFrameAttrsMap(HashMap<String, FrameAttrs>);
pub struct FuncFrameAttrsMap(FnvHashMap<String, FrameAttrs>);

impl FuncFrameAttrsMap {
/// Parse frame attributes from a file.
Expand Down Expand Up @@ -101,7 +102,7 @@ pub(super) struct FrameAttrs {
/// If set to None, the title is dynamically generated based on the function name.
pub(super) title: Option<String>,

pub(super) attrs: FnvHashMap<String, String>,
pub(super) attrs: AttrMap<String, String>,
}

impl FrameAttrs {
Expand Down Expand Up @@ -211,8 +212,8 @@ mod test {
let s = vec![foo, bar].join("\n");
let r = s.as_bytes();

let mut expected_inner = HashMap::new();
let foo_attrs: FnvHashMap<String, String> = convert_args!(hashmap!(
let mut expected_inner = FnvHashMap::default();
let foo_attrs: AttrMap<String, String> = convert_args!(hashmap!(
"class" => "foo class",
"xlink:href" => "foo href",
"target" => "foo target",
Expand All @@ -232,7 +233,7 @@ mod test {
},
);

let bar_attrs: FnvHashMap<String, String> = convert_args!(hashmap!(
let bar_attrs: AttrMap<String, String> = convert_args!(hashmap!(
"class" => "bar class",
"xlink:href" => "bar href",
"aextra1" => "foo",
Expand Down
14 changes: 7 additions & 7 deletions tests/data/flamegraph/nameattr/nameattr.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.