Skip to content

Commit 760a05b

Browse files
committed
Move benchmarks into bench sub-crate
1 parent 8df3dc5 commit 760a05b

File tree

11 files changed

+30
-25
lines changed

11 files changed

+30
-25
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "sse4-strstr/src/sse4-strstr"]
2-
path = sse4-strstr/src/sse4-strstr
2+
path = bench/sse4-strstr/src/sse4-strstr
33
url = https://github.com/WojciechMula/sse4-strstr.git

Cargo.toml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,8 @@ repository = "https://github.com/cloudflare/sliceslice-rs"
99
license = "MIT"
1010
keywords = ["search", "text", "string", "single", "simd"]
1111

12-
[lib]
13-
bench = false
14-
1512
[dependencies]
1613
memchr = "2.3"
1714

18-
[dev-dependencies]
19-
criterion = "0.3"
20-
memmem = "0.1"
21-
sse4-strstr = { path = "sse4-strstr" }
22-
twoway = "0.2"
23-
24-
[[bench]]
25-
name = "i386"
26-
harness = false
27-
28-
[[bench]]
29-
name = "random"
30-
harness = false
31-
3215
[profile.release]
3316
debug = true

bench/Cargo.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "sliceslice-bench"
3+
version = "0.0.0"
4+
edition = "2018"
5+
publish = false
6+
7+
[dependencies]
8+
criterion = "0.3"
9+
memmem = "0.1"
10+
sliceslice = { path = ".." }
11+
sse4-strstr = { path = "sse4-strstr" }
12+
twoway = "0.2"
13+
14+
[[bench]]
15+
name = "i386"
16+
harness = false
17+
18+
[[bench]]
19+
name = "random"
20+
harness = false
21+
22+
[profile.release]
23+
debug = true

benches/i386.rs renamed to bench/benches/i386.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use criterion::{black_box, criterion_group, criterion_main, Criterion};
22
use memmem::{Searcher, TwoWaySearcher};
33
use std::{
4-
fs::{self, File},
4+
fs::File,
55
io::{BufRead, BufReader},
66
};
77

88
fn search_short_haystack(c: &mut Criterion) {
9-
let mut needles = BufReader::new(File::open("data/words.txt").unwrap())
9+
let mut needles = BufReader::new(File::open("../data/words.txt").unwrap())
1010
.lines()
1111
.map(Result::unwrap)
1212
.collect::<Vec<_>>();
@@ -88,10 +88,9 @@ fn search_short_haystack(c: &mut Criterion) {
8888
}
8989

9090
fn search_long_haystack(c: &mut Criterion) {
91-
let haystack = fs::read("data/i386.txt").unwrap();
92-
let haystack = String::from_utf8_lossy(&haystack);
91+
let haystack = include_str!("../../data/haystack");
9392

94-
let needles = BufReader::new(File::open("data/words.txt").unwrap())
93+
let needles = BufReader::new(File::open("../data/words.txt").unwrap())
9594
.lines()
9695
.map(Result::unwrap)
9796
.collect::<Vec<_>>();

benches/random.rs renamed to bench/benches/random.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criteri
22
use memmem::{Searcher, TwoWaySearcher};
33

44
fn search(c: &mut Criterion) {
5-
let haystack = include_str!("../data/haystack");
6-
let needle = include_str!("../data/needle");
5+
let haystack = include_str!("../../data/haystack");
6+
let needle = include_str!("../../data/needle");
77

88
let sizes = [1, 5, 10, 20, 50, 100, 1000];
99

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)