forked from rust-phf/rust-phf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-v0.7.5' into release
- Loading branch information
Showing
14 changed files
with
170 additions
and
31 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
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
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,16 +1,16 @@ | ||
[package] | ||
name = "phf_codegen" | ||
authors = ["Steven Fackler <sfackler@gmail.com>"] | ||
version = "0.7.4" | ||
version = "0.7.5" | ||
license = "MIT" | ||
description = "Codegen library for PHF types" | ||
repository = "https://github.com/sfackler/rust-phf" | ||
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.4/phf_codegen" | ||
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.5/phf_codegen" | ||
|
||
[dependencies.phf_generator] | ||
path = "../phf_generator" | ||
version = "=0.7.4" | ||
version = "=0.7.5" | ||
|
||
[dependencies.phf_shared] | ||
path = "../phf_shared" | ||
version = "=0.7.4" | ||
version = "=0.7.5" |
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,15 +1,15 @@ | ||
[package] | ||
name = "phf_generator" | ||
authors = ["Steven Fackler <sfackler@gmail.com>"] | ||
version = "0.7.4" | ||
version = "0.7.5" | ||
license = "MIT" | ||
description = "PHF generation logic" | ||
repository = "https://github.com/sfackler/rust-phf" | ||
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.4/phf_generator" | ||
documentation = "https://sfackler.github.io/rust-phf/doc/v0.7.5/phf_generator" | ||
|
||
[dependencies] | ||
rand = "0.3" | ||
|
||
[dependencies.phf_shared] | ||
path = "../phf_shared" | ||
version = "=0.7.4" | ||
version = "=0.7.5" |
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
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 |
---|---|---|
@@ -0,0 +1,133 @@ | ||
#![feature(plugin, test)] | ||
#![plugin(phf_macros)] | ||
|
||
extern crate test; | ||
extern crate phf; | ||
|
||
mod map { | ||
use std::collections::{BTreeMap, HashMap}; | ||
use test::Bencher; | ||
|
||
use phf; | ||
|
||
macro_rules! map_and_match { | ||
($map:ident, $f:ident, $($key:expr => $value:expr,)+) => { | ||
static $map: phf::Map<&'static str, usize> = phf_map! { | ||
$($key => $value),+ | ||
}; | ||
|
||
fn $f(key: &str) -> Option<usize> { | ||
match key { | ||
$($key => Some($value),)+ | ||
_ => None | ||
} | ||
} | ||
} | ||
} | ||
|
||
map_and_match! { MAP, match_get, | ||
"apple" => 0, | ||
"banana" => 1, | ||
"carrot" => 2, | ||
"doughnut" => 3, | ||
"eggplant" => 4, | ||
"frankincene" => 5, | ||
"grapes" => 6, | ||
"haggis" => 7, | ||
"ice cream" => 8, | ||
"jelly beans" => 9, | ||
"kaffir lime leaves" => 10, | ||
"lemonade" => 11, | ||
"mashmallows" => 12, | ||
"nectarines" => 13, | ||
"oranges" => 14, | ||
"pineapples" => 15, | ||
"quinoa" => 16, | ||
"rosemary" => 17, | ||
"sourdough" => 18, | ||
"tomatoes" => 19, | ||
"unleavened bread" => 20, | ||
"vanilla" => 21, | ||
"watermelon" => 22, | ||
"xinomavro grapes" => 23, | ||
"yogurt" => 24, | ||
"zucchini" => 25, | ||
} | ||
|
||
#[bench] | ||
fn bench_match_some(b: &mut Bencher) { | ||
b.iter(|| { | ||
assert_eq!(match_get("zucchini").unwrap(), 25); | ||
}) | ||
} | ||
|
||
#[bench] | ||
fn bench_match_none(b: &mut Bencher) { | ||
b.iter(|| { | ||
assert_eq!(match_get("potato"), None); | ||
}) | ||
} | ||
|
||
#[bench] | ||
fn bench_btreemap_some(b: &mut Bencher) { | ||
let mut map = BTreeMap::new(); | ||
for (key, value) in MAP.entries() { | ||
map.insert(*key, *value); | ||
} | ||
|
||
b.iter(|| { | ||
assert_eq!(map.get("zucchini").unwrap(), &25); | ||
}) | ||
} | ||
|
||
#[bench] | ||
fn bench_hashmap_some(b: &mut Bencher) { | ||
let mut map = HashMap::new(); | ||
for (key, value) in MAP.entries() { | ||
map.insert(*key, *value); | ||
} | ||
|
||
b.iter(|| { | ||
assert_eq!(map.get("zucchini").unwrap(), &25); | ||
}) | ||
} | ||
|
||
#[bench] | ||
fn bench_phf_some(b: &mut Bencher) { | ||
b.iter(|| { | ||
assert_eq!(MAP.get("zucchini").unwrap(), &25); | ||
}) | ||
} | ||
|
||
#[bench] | ||
fn bench_btreemap_none(b: &mut Bencher) { | ||
let mut map = BTreeMap::new(); | ||
for (key, value) in MAP.entries() { | ||
map.insert(*key, *value); | ||
} | ||
|
||
b.iter(|| { | ||
assert_eq!(map.get("potato"), None); | ||
}) | ||
} | ||
|
||
|
||
#[bench] | ||
fn bench_hashmap_none(b: &mut Bencher) { | ||
let mut map = BTreeMap::new(); | ||
for (key, value) in MAP.entries() { | ||
map.insert(*key, *value); | ||
} | ||
|
||
b.iter(|| { | ||
assert_eq!(map.get("potato"), None); | ||
}) | ||
} | ||
|
||
#[bench] | ||
fn bench_phf_none(b: &mut Bencher) { | ||
b.iter(|| { | ||
assert_eq!(MAP.get("potato"), None); | ||
}) | ||
} | ||
} |
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
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