Skip to content

Commit

Permalink
Benchmarks use longer static strings
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Jul 17, 2024
1 parent d438d36 commit e65ac7a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions integration-tests/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fn main() {
"a",
"b",
"address",
"defaults",
"area",
"body",
"font-weight",
Expand Down
8 changes: 4 additions & 4 deletions integration-tests/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ bench_all!([eq ne lt clone_string]
for longer_string = super::longer_dynamic_a, super::longer_dynamic_b);

bench_all!([eq ne intern as_ref clone is_static lt]
for static_atom = test_atom!("a"), test_atom!("b"));
for static_atom = test_atom!("defaults"), test_atom!("font-weight"));

bench_all!([intern as_ref clone is_inline]
for short_inline_atom = mk("e"), mk("f"));
Expand All @@ -168,13 +168,13 @@ bench_all!([eq ne intern as_ref clone is_dynamic lt]
for longer_dynamic_atom = mk(super::longer_dynamic_a), mk(super::longer_dynamic_b));

bench_all!([intern as_ref clone is_static]
for static_at_runtime = mk("a"), mk("b"));
for static_at_runtime = mk("defaults"), mk("font-weight"));

bench_all!([ne lt x_static y_inline]
for static_vs_inline = test_atom!("a"), mk("f"));
for static_vs_inline = test_atom!("defaults"), mk("f"));

bench_all!([ne lt x_static y_dynamic]
for static_vs_dynamic = test_atom!("a"), mk(super::longer_dynamic_b));
for static_vs_dynamic = test_atom!("defaults"), mk(super::longer_dynamic_b));

bench_all!([ne lt x_inline y_dynamic]
for inline_vs_dynamic = mk("e"), mk(super::longer_dynamic_b));
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ fn test_as_slice() {
#[test]
fn test_types() {
assert!(Atom::from("").is_static());
assert!(Atom::from("defaults").is_static());
assert!(Atom::from("font-weight").is_static());
assert!(Atom::from("id").is_static());
assert!(Atom::from("body").is_static());
assert!(Atom::from("a").is_static());
assert!(Atom::from("address").is_static());
assert!(Atom::from("c").is_inline());
assert!(Atom::from("zz").is_inline());
assert!(Atom::from("zzz").is_inline());
Expand Down Expand Up @@ -168,6 +171,8 @@ fn repr() {
// static atom table, the tag values, etc.

// Static atoms
check_static("defaults", test_atom!("defaults"));
check_static("font-weight", test_atom!("font-weight"));
check_static("a", test_atom!("a"));
check_static("address", test_atom!("address"));
check_static("area", test_atom!("area"));
Expand All @@ -193,7 +198,9 @@ fn test_threads() {

#[test]
fn atom_macro() {
assert_eq!(test_atom!("a"), Atom::from("a"));
assert_eq!(test_atom!("body"), Atom::from("body"));
assert_eq!(test_atom!("address"), Atom::from("address"));
assert_eq!(test_atom!("font-weight"), Atom::from("font-weight"));
}

Expand Down Expand Up @@ -292,6 +299,7 @@ fn test_from_string() {

#[test]
fn test_try_static() {
assert!(Atom::try_static("defaults").is_some());
assert!(Atom::try_static("head").is_some());
assert!(Atom::try_static("not in the static table").is_none());
}
Expand Down

0 comments on commit e65ac7a

Please sign in to comment.