bench: add criterion benchmarks

This represents an initial go at adding comprehensive criterion
benchmarks. We hit every public API function, and vary benchmarks based
on both corpus size and match frequency.

The point of this exercise is to establish a baseline on the status quo,
and make sure we don't introduce any major regressions after a
refactoring toward vendor intrinsics.
This commit is contained in:
Andrew Gallant
2018-09-09 20:01:36 -04:00
parent 15b13e5a61
commit 4a09815c87
10 changed files with 14507 additions and 1 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ tags
examples/ss10pusa.csv
build
target
Cargo.lock
/Cargo.lock
scratch*
bench_large/huge
tmp/
+687
View File
@@ -0,0 +1,687 @@
[[package]]
name = "aho-corasick"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ansi_term"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "atty"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "backtrace"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
"cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "backtrace-sys"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "bitflags"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "byteorder"
version = "1.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cast"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cc"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "cfg-if"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "chrono"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "clap"
version = "2.32.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "criterion"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
"criterion-plot 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"criterion-stats 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"csv 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"handlebars 0.32.4 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools-num 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.78 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.78 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
"simplelog 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "criterion-plot"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "criterion-stats"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"thread-scoped 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "csv"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"csv-core 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.78 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "csv-core"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "either"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "failure"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
"failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "failure_derive"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
"synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fuchsia-zircon"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "fuchsia-zircon-sys"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "handlebars"
version = "0.32.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"pest 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pest_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.78 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "itertools"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "itertools-num"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "itoa"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "lazy_static"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libc"
version = "0.2.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "log"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "memchr"
version = "2.0.2"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "memchr"
version = "2.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "memchr-bench"
version = "0.0.1"
dependencies = [
"criterion 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.0.2",
]
[[package]]
name = "num-integer"
version = "0.1.39"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "num-traits"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "num_cpus"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "pest"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "pest_derive"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"pest 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro2"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "quick-error"
version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "quote"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "quote"
version = "0.6.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rand"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "redox_syscall"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "redox_termios"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "rustc-demangle"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "ryu"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "same-file"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde"
version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "serde_derive"
version = "1.0.78"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "serde_json"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.78 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "simplelog"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
"term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "strsim"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "syn"
version = "0.11.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syn"
version = "0.14.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "syn"
version = "0.15.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "synom"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "synstructure"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "term"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "termion"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "textwrap"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "thread-scoped"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "thread_local"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "time"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "ucd-util"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-width"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unicode-xid"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "utf8-ranges"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "vec_map"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "version_check"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "walkdir"
version = "2.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"same-file 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "winapi-util"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[metadata]
"checksum aho-corasick 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "68f56c7353e5a9547cbd76ed90f7bb5ffc3ba09d4ea9bd1d8c06c8b1142eeb5a"
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a"
"checksum backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "c66d56ac8dabd07f6aacdaf633f4b8262f5b3601a810a0dcddffd5c22c69daa0"
"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781"
"checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427"
"checksum cc 1.0.24 (registry+https://github.com/rust-lang/crates.io-index)" = "70f2a88c2e69ceee91c209d8ef25b81fc1a65f42c7f14dfd59d1fed189e514d1"
"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3"
"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
"checksum criterion 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c47d2b548c5647e1a436dc0cb78d4ebf51b6bf7ab101ed76662828bdd4d3a24a"
"checksum criterion-plot 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6e649d6aacdbbdb94ec659561a309a71336fc5655ed408f3afd28df2fc0c4f4f"
"checksum criterion-stats 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ff43cac80562f91ead0b617c1be74edf350adfaa195809d355de98dfc8f9237d"
"checksum csv 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bbb6d75aae072248e381715437855a69595e5a97d3abbf748fe7a95e65d77fa"
"checksum csv-core 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "4dd8e6d86f7ba48b4276ef1317edc8cc36167546d8972feb4a2b5fec0b374105"
"checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0"
"checksum failure 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7efb22686e4a466b1ec1a15c2898f91fa9cb340452496dca654032de20ff95b9"
"checksum failure_derive 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "946d0e98a50d9831f5d589038d2ca7f8f455b1c21028c0db0e84116a12696426"
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum handlebars 0.32.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d89ec99d1594f285d4590fc32bac5f75cdab383f1123d504d27862c644a807dd"
"checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450"
"checksum itertools-num 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "83ca7b70b838f2e34bc6c2f367a1ed1cfe34fb82464adecadd31cdcc7da882fc"
"checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b"
"checksum lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca488b89a5657b0a2ecd45b95609b3e848cf1755da332a0da46e2b2b1cb371a7"
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
"checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f"
"checksum memchr 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a3b4142ab8738a78c51896f704f83c11df047ff1bda9a92a661aa6361552d93d"
"checksum num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "e83d528d2677f0518c570baf2b7abdcf0cd2d248860b68507bdcb3e91d4c0cea"
"checksum num-traits 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "630de1ef5cc79d0cdd78b7e33b81f083cbfe90de0f4b2b2f07f905867c70e9fe"
"checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30"
"checksum pest 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0fce5d8b5cc33983fc74f78ad552b5522ab41442c4ca91606e4236eb4b5ceefc"
"checksum pest_derive 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3294f437119209b084c797604295f40227cffa35c57220b1e99a6ff3bf8ee4"
"checksum proc-macro2 0.4.19 (registry+https://github.com/rust-lang/crates.io-index)" = "ffe022fb8c8bd254524b0b3305906c1921fa37a84a644e29079a9e62200c3901"
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
"checksum quote 0.6.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dd636425967c33af890042c483632d33fa7a18f19ad1d7ea72e8998c6ef8dea5"
"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
"checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum regex 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2069749032ea3ec200ca51e4a31df41759190a88edca0d2d86ee8bedf7073341"
"checksum regex-syntax 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "747ba3b235651f6e2f67dfa8bcdcd073ddb7c243cb21c442fc12395dfcac212d"
"checksum rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "bcfe5b13211b4d78e5c2cadfebd7769197d95c639c35a50057eb4c05de811395"
"checksum ryu 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7153dd96dade874ab973e098cb62fcdbb89a03682e46b144fd09550998d4a4a7"
"checksum same-file 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "10f7794e2fda7f594866840e95f5c5962e886e228e68b6505885811a94dd728c"
"checksum serde 1.0.78 (registry+https://github.com/rust-lang/crates.io-index)" = "92ec94e2754699adddbbc4f555791bd3acc2a2f5574cba16c93a4a9cf4a04415"
"checksum serde_derive 1.0.78 (registry+https://github.com/rust-lang/crates.io-index)" = "0fb622d85245add5327d4f08b2d24fd51fa5d35fe1bba19ee79a1f211e9ac0ff"
"checksum serde_json 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "59790990c5115d16027f00913e2e66de23a51f70422e549d2ad68c8c5f268f1c"
"checksum simplelog 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9cc12b39fdf4c9a07f88bffac2d628f0118ed5ac077a4b0feece61fadf1429e5"
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741"
"checksum syn 0.15.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e5c1514eb7bb4216fc722b3cd08783d326d7de0d62f6d5e48a774f610bc97cb6"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
"checksum synstructure 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb9b7550d063ea184027c9b8c20ac167cd36d3e06b3a40bceb9d746dc1a7b7"
"checksum term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6b677dd1e8214ea1ef4297f85dbcbed8e8cdddb561040cc998ca2551c37561"
"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6"
"checksum thread-scoped 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bcbb6aa301e5d3b0b5ef639c9a9c7e2f1c944f177b460c04dc24c69b1fa2bd99"
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
"checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b"
"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d"
"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum utf8-ranges 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd70f467df6810094968e2fce0ee1bd0e87157aceb026a8c083bcf5e25b9efe4"
"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"
"checksum version_check 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "7716c242968ee87e5542f8021178248f267f295a5c4803beae8b8b7fd9bc6051"
"checksum walkdir 2.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "af464bc7be7b785c7ac72e266a6b67c4c9070155606f51655a650a6686204e35"
"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "afc5508759c5bf4285e61feb862b6083c8480aec864fa17a81fdec6f69b461ab"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
+21
View File
@@ -0,0 +1,21 @@
[package]
publish = false
name = "memchr-bench"
version = "0.0.1"
authors = ["Andrew Gallant <jamslam@gmail.com>"]
description = "Criterion benchmark suite for memchr."
homepage = "https://github.com/BurntSushi/rust-memchr"
repository = "https://github.com/BurntSushi/rust-memchr"
license = "Unlicense/MIT"
[lib]
bench = false
[[bench]]
name = "memchr"
harness = false
path = "src/bench.rs"
[dependencies]
criterion = "0.2"
memchr = { version = "*", path = ".." }
File diff suppressed because it is too large Load Diff
+10
View File
@@ -0,0 +1,10 @@
Mr. Sherlock Holmes, who was usually very late in the mornings, save
upon those not infrequent occasions when he was up all night, was seated
at the breakfast table. I stood upon the hearth-rug and picked up the
stick which our visitor had left behind him the night before. It was a
fine, thick piece of wood, bulbous-headed, of the sort which is known as
a "Penang lawyer." Just under the head was a broad silver band nearly
an inch across. "To James Mortimer, M.R.C.S., from his friends of the
C.C.H.," was engraved upon it, with the date "1884." It was just such a
stick as the old-fashioned family practitioner used to carry--dignified,
solid, and reassuring.
+1
View File
@@ -0,0 +1 @@
Mr. Sherlock Holmes, who was usually very late in the mornings, save
+370
View File
@@ -0,0 +1,370 @@
#![allow(dead_code)]
#[macro_use]
extern crate criterion;
extern crate memchr;
use criterion::{Bencher, Benchmark, Criterion, Throughput};
use imp::{
memchr1_count, memchr2_count, memchr3_count,
memrchr1_count,
naive1_count,
};
use inputs::{
Input, Search1, Search2, Search3,
HUGE, SMALL, TINY, EMPTY,
};
mod imp;
mod inputs;
fn all(c: &mut Criterion) {
define_input1(c, "memchr1/huge", HUGE, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count,
memchr1_count(search.byte1.byte, search.corpus),
);
});
});
define_input1(c, "memchr1/small", SMALL, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count,
memchr1_count(search.byte1.byte, search.corpus),
);
});
});
define_input1(c, "memchr1/tiny", TINY, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count,
memchr1_count(search.byte1.byte, search.corpus),
);
});
});
define_input1(c, "memchr1/empty", EMPTY, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count,
memchr1_count(search.byte1.byte, search.corpus),
);
});
});
define_input2(c, "memchr2/huge", HUGE, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count + search.byte2.count,
memchr2_count(
search.byte1.byte,
search.byte2.byte,
search.corpus,
)
);
});
});
define_input2(c, "memchr2/small", SMALL, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count + search.byte2.count,
memchr2_count(
search.byte1.byte,
search.byte2.byte,
search.corpus,
)
);
});
});
define_input2(c, "memchr2/tiny", TINY, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count + search.byte2.count,
memchr2_count(
search.byte1.byte,
search.byte2.byte,
search.corpus,
)
);
});
});
define_input2(c, "memchr2/empty", EMPTY, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count + search.byte2.count,
memchr2_count(
search.byte1.byte,
search.byte2.byte,
search.corpus,
)
);
});
});
define_input3(c, "memchr3/huge", HUGE, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count + search.byte2.count + search.byte3.count,
memchr3_count(
search.byte1.byte,
search.byte2.byte,
search.byte3.byte,
search.corpus,
)
);
});
});
define_input3(c, "memchr3/small", SMALL, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count + search.byte2.count + search.byte3.count,
memchr3_count(
search.byte1.byte,
search.byte2.byte,
search.byte3.byte,
search.corpus,
)
);
});
});
define_input3(c, "memchr3/tiny", TINY, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count + search.byte2.count + search.byte3.count,
memchr3_count(
search.byte1.byte,
search.byte2.byte,
search.byte3.byte,
search.corpus,
)
);
});
});
define_input3(c, "memchr3/empty", EMPTY, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count + search.byte2.count + search.byte3.count,
memchr3_count(
search.byte1.byte,
search.byte2.byte,
search.byte3.byte,
search.corpus,
)
);
});
});
define_input1(c, "memrchr1/huge", HUGE, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count,
memrchr1_count(search.byte1.byte, search.corpus)
);
});
});
define_input1(c, "memrchr1/small", SMALL, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count,
memrchr1_count(search.byte1.byte, search.corpus)
);
});
});
define_input1(c, "memrchr1/tiny", TINY, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count,
memrchr1_count(search.byte1.byte, search.corpus)
);
});
});
define_input1(c, "memrchr1/empty", EMPTY, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count,
memrchr1_count(search.byte1.byte, search.corpus)
);
});
});
define_input1(c, "naive1/huge", HUGE, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count,
naive1_count(search.byte1.byte, search.corpus),
);
});
});
define_input1(c, "naive1/small", SMALL, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count,
naive1_count(search.byte1.byte, search.corpus),
);
});
});
define_input1(c, "naive1/tiny", TINY, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count,
naive1_count(search.byte1.byte, search.corpus),
);
});
});
define_input1(c, "naive1/empty", EMPTY, move |search, b| {
b.iter(|| {
assert_eq!(
search.byte1.count,
naive1_count(search.byte1.byte, search.corpus),
);
});
});
}
fn define_input1<'i>(
c: &mut Criterion,
group: &str,
input: Input,
bench: impl FnMut(Search1, &mut Bencher) + Clone + 'static,
) {
if let Some(search) = input.never1() {
let mut bench = bench.clone();
define(c, group, "never", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.rare1() {
let mut bench = bench.clone();
define(c, group, "rare", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.uncommon1() {
let mut bench = bench.clone();
define(c, group, "uncommon", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.common1() {
let mut bench = bench.clone();
define(c, group, "common", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.verycommon1() {
let mut bench = bench.clone();
define(c, group, "verycommon", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.supercommon1() {
let mut bench = bench.clone();
define(c, group, "supercommon", input.corpus, move |b| {
bench(search, b)
});
}
}
fn define_input2<'i>(
c: &mut Criterion,
group: &str,
input: Input,
bench: impl FnMut(Search2, &mut Bencher) + Clone + 'static,
) {
if let Some(search) = input.never2() {
let mut bench = bench.clone();
define(c, group, "never", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.rare2() {
let mut bench = bench.clone();
define(c, group, "rare", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.uncommon2() {
let mut bench = bench.clone();
define(c, group, "uncommon", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.common2() {
let mut bench = bench.clone();
define(c, group, "common", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.verycommon2() {
let mut bench = bench.clone();
define(c, group, "verycommon", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.supercommon2() {
let mut bench = bench.clone();
define(c, group, "supercommon", input.corpus, move |b| {
bench(search, b)
});
}
}
fn define_input3<'i>(
c: &mut Criterion,
group: &str,
input: Input,
bench: impl FnMut(Search3, &mut Bencher) + Clone + 'static,
) {
if let Some(search) = input.never3() {
let mut bench = bench.clone();
define(c, group, "never", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.rare3() {
let mut bench = bench.clone();
define(c, group, "rare", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.uncommon3() {
let mut bench = bench.clone();
define(c, group, "uncommon", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.common3() {
let mut bench = bench.clone();
define(c, group, "common", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.verycommon3() {
let mut bench = bench.clone();
define(c, group, "verycommon", input.corpus, move |b| {
bench(search, b)
});
}
if let Some(search) = input.supercommon3() {
let mut bench = bench.clone();
define(c, group, "supercommon", input.corpus, move |b| {
bench(search, b)
});
}
}
fn define(
c: &mut Criterion,
group_name: &str,
bench_name: &str,
corpus: &[u8],
bench: impl FnMut(&mut Bencher) + 'static,
) {
let tput = Throughput::Bytes(corpus.len() as u32);
let benchmark = Benchmark::new(bench_name, bench).throughput(tput);
c.bench(group_name, benchmark);
}
criterion_group!(does_not_matter, all);
criterion_main!(does_not_matter);
+27
View File
@@ -0,0 +1,27 @@
use memchr::{Memchr, Memchr2, Memchr3, memrchr};
pub fn memchr1_count(b1: u8, haystack: &[u8]) -> usize {
Memchr::new(b1, haystack).count()
}
pub fn naive1_count(b1: u8, haystack: &[u8]) -> usize {
haystack.iter().filter(|&&b| b == b1).count()
}
pub fn memchr2_count(b1: u8, b2: u8, haystack: &[u8]) -> usize {
Memchr2::new(b1, b2, haystack).count()
}
pub fn memchr3_count(b1: u8, b2: u8, b3: u8, haystack: &[u8]) -> usize {
Memchr3::new(b1, b2, b3, haystack).count()
}
pub fn memrchr1_count(b1: u8, haystack: &[u8]) -> usize {
let mut count = 0;
let mut end = haystack.len();
while let Some(i) = memrchr(b1, &haystack[..end]) {
end = i;
count += 1;
}
count
}
+335
View File
@@ -0,0 +1,335 @@
#![allow(dead_code)]
pub const HUGE: Input = Input {
corpus: include_bytes!("../data/sherlock-holmes-huge.txt"),
never: &[
SearchByte { byte: b'<', count: 0 },
SearchByte { byte: b'>', count: 0 },
SearchByte { byte: b'=', count: 0 },
],
rare: &[
SearchByte { byte: b'z', count: 151 },
SearchByte { byte: b'R', count: 275 },
SearchByte { byte: b'J', count: 120 },
],
uncommon: &[
SearchByte { byte: b'b', count: 6124 },
SearchByte { byte: b'p', count: 6989 },
SearchByte { byte: b'.', count: 6425 },
],
common: &[
SearchByte { byte: b'a', count: 35301 },
SearchByte { byte: b't', count: 39268 },
SearchByte { byte: b'o', count: 34495 },
],
verycommon: &[
SearchByte { byte: b' ', count: 97626 },
],
supercommon: &[],
};
pub const TINY: Input = Input {
corpus: include_bytes!("../data/sherlock-holmes-tiny.txt"),
never: &[
SearchByte { byte: b'<', count: 0 },
SearchByte { byte: b'>', count: 0 },
SearchByte { byte: b'=', count: 0 },
],
rare: &[
SearchByte { byte: b'.', count: 1 },
SearchByte { byte: b'H', count: 1 },
SearchByte { byte: b'M', count: 1 },
],
uncommon: &[
SearchByte { byte: b'l', count: 5 },
SearchByte { byte: b's', count: 5 },
SearchByte { byte: b'e', count: 6 },
],
common: &[
SearchByte { byte: b' ', count: 11 },
],
verycommon: &[],
supercommon: &[],
};
pub const SMALL: Input = Input {
corpus: include_bytes!("../data/sherlock-holmes-small.txt"),
never: &[
SearchByte { byte: b'<', count: 0 },
SearchByte { byte: b'>', count: 0 },
SearchByte { byte: b'=', count: 0 },
],
rare: &[
SearchByte { byte: b'R', count: 1 },
SearchByte { byte: b'P', count: 1 },
SearchByte { byte: b'T', count: 1 },
],
uncommon: &[
SearchByte { byte: b'b', count: 8 },
SearchByte { byte: b'g', count: 8 },
SearchByte { byte: b'p', count: 8 },
],
common: &[
SearchByte { byte: b'a', count: 44 },
SearchByte { byte: b'h', count: 34 },
SearchByte { byte: b'i', count: 35 },
],
verycommon: &[
SearchByte { byte: b' ', count: 106 },
],
supercommon: &[],
};
pub const EMPTY: Input = Input {
corpus: &[],
never: &[
SearchByte { byte: b'a', count: 0 },
SearchByte { byte: b'b', count: 0 },
SearchByte { byte: b'c', count: 0 },
],
rare: &[],
uncommon: &[],
common: &[],
verycommon: &[],
supercommon: &[],
};
/// A description of an input to benchmark on.
#[derive(Clone, Copy, Debug)]
pub struct Input {
/// The bytes to search.
pub corpus: &'static [u8],
/// Distinct bytes that never occur in the input.
pub never: &'static [SearchByte],
/// Distinct bytes that occur very rarely (<0.1%).
pub rare: &'static [SearchByte],
/// Distinct bytes that are uncommon (~1%).
pub uncommon: &'static [SearchByte],
/// Distinct bytes that are common (~5%).
pub common: &'static [SearchByte],
/// Distinct bytes that are very common (~10%).
pub verycommon: &'static [SearchByte],
/// Distinct bytes that are super common (>90%).
pub supercommon: &'static [SearchByte],
}
impl Input {
/// Return all of this input's "never" bytes only if there are at least
/// `min` of them.
fn never(&self, min: usize) -> Option<&'static [SearchByte]> {
if self.never.len() < min {
None
} else {
Some(self.never)
}
}
pub fn never1(&self) -> Option<Search1> {
self.never(1).and_then(|bytes| Search1::new(self.corpus, bytes))
}
pub fn never2(&self) -> Option<Search2> {
self.never(2).and_then(|bytes| Search2::new(self.corpus, bytes))
}
pub fn never3(&self) -> Option<Search3> {
self.never(3).and_then(|bytes| Search3::new(self.corpus, bytes))
}
/// Return all of this input's "rare" bytes only if there are at least
/// `min` of them.
fn rare(&self, min: usize) -> Option<&'static [SearchByte]> {
if self.rare.len() < min {
None
} else {
Some(self.rare)
}
}
pub fn rare1(&self) -> Option<Search1> {
self.rare(1).and_then(|bytes| Search1::new(self.corpus, bytes))
}
pub fn rare2(&self) -> Option<Search2> {
self.rare(2).and_then(|bytes| Search2::new(self.corpus, bytes))
}
pub fn rare3(&self) -> Option<Search3> {
self.rare(3).and_then(|bytes| Search3::new(self.corpus, bytes))
}
/// Return all of this input's "uncommon" bytes only if there are at least
/// `min` of them.
fn uncommon(&self, min: usize) -> Option<&'static [SearchByte]> {
if self.uncommon.len() < min {
None
} else {
Some(self.uncommon)
}
}
pub fn uncommon1(&self) -> Option<Search1> {
self.uncommon(1).and_then(|bytes| Search1::new(self.corpus, bytes))
}
pub fn uncommon2(&self) -> Option<Search2> {
self.uncommon(2).and_then(|bytes| Search2::new(self.corpus, bytes))
}
pub fn uncommon3(&self) -> Option<Search3> {
self.uncommon(3).and_then(|bytes| Search3::new(self.corpus, bytes))
}
/// Return all of this input's "common" bytes only if there are at least
/// `min` of them.
fn common(&self, min: usize) -> Option<&'static [SearchByte]> {
if self.common.len() < min {
None
} else {
Some(self.common)
}
}
pub fn common1(&self) -> Option<Search1> {
self.common(1).and_then(|bytes| Search1::new(self.corpus, bytes))
}
pub fn common2(&self) -> Option<Search2> {
self.common(2).and_then(|bytes| Search2::new(self.corpus, bytes))
}
pub fn common3(&self) -> Option<Search3> {
self.common(3).and_then(|bytes| Search3::new(self.corpus, bytes))
}
/// Return all of this input's "verycommon" bytes only if there are at
/// least `min` of them.
fn verycommon(&self, min: usize) -> Option<&'static [SearchByte]> {
if self.verycommon.len() < min {
None
} else {
Some(self.verycommon)
}
}
pub fn verycommon1(&self) -> Option<Search1> {
self.verycommon(1).and_then(|bytes| Search1::new(self.corpus, bytes))
}
pub fn verycommon2(&self) -> Option<Search2> {
self.verycommon(2).and_then(|bytes| Search2::new(self.corpus, bytes))
}
pub fn verycommon3(&self) -> Option<Search3> {
self.verycommon(3).and_then(|bytes| Search3::new(self.corpus, bytes))
}
/// Return all of this input's "supercommon" bytes only if there are at
/// least `min` of them.
fn supercommon(&self, min: usize) -> Option<&'static [SearchByte]> {
if self.supercommon.len() < min {
None
} else {
Some(self.supercommon)
}
}
pub fn supercommon1(&self) -> Option<Search1> {
self.supercommon(1).and_then(|bytes| Search1::new(self.corpus, bytes))
}
pub fn supercommon2(&self) -> Option<Search2> {
self.supercommon(2).and_then(|bytes| Search2::new(self.corpus, bytes))
}
pub fn supercommon3(&self) -> Option<Search3> {
self.supercommon(3).and_then(|bytes| Search3::new(self.corpus, bytes))
}
}
/// A description of a single byte, along with the number of times it is
/// expected to occur for a particular data source.
#[derive(Clone, Copy, Debug)]
pub struct SearchByte {
/// A byte. Any byte.
pub byte: u8,
/// The number of times it is expected to occur.
pub count: usize,
}
/// A description of a search for one particular byte.
#[derive(Clone, Copy, Debug)]
pub struct Search1 {
/// The thing to search.
pub corpus: &'static [u8],
/// The thing to search for. One byte.
pub byte1: SearchByte,
}
impl Search1 {
pub fn new(
corpus: &'static [u8],
bytes: &[SearchByte],
) -> Option<Search1> {
if bytes.len() < 1 {
None
} else {
Some(Search1 { corpus, byte1: bytes[0] })
}
}
}
/// A description of a search for one of two particular bytes.
#[derive(Clone, Copy, Debug)]
pub struct Search2 {
/// The thing to search.
pub corpus: &'static [u8],
/// One of the things to search for.
pub byte1: SearchByte,
/// The other thing to search for.
pub byte2: SearchByte,
}
impl Search2 {
pub fn new(
corpus: &'static [u8],
bytes: &[SearchByte],
) -> Option<Search2> {
if bytes.len() < 2 {
None
} else {
Some(Search2 { corpus, byte1: bytes[0], byte2: bytes[1] })
}
}
}
/// A description of a search for one of three particular bytes.
#[derive(Clone, Copy, Debug)]
pub struct Search3 {
/// The thing to search.
pub corpus: &'static [u8],
/// One of the things to search for.
pub byte1: SearchByte,
/// The other thing to search for.
pub byte2: SearchByte,
/// Another thing to search for.
pub byte3: SearchByte,
}
impl Search3 {
pub fn new(
corpus: &'static [u8],
bytes: &[SearchByte],
) -> Option<Search3> {
if bytes.len() < 3 {
None
} else {
Some(Search3 {
corpus,
byte1: bytes[0],
byte2: bytes[1],
byte3: bytes[2],
})
}
}
}
+2
View File
@@ -0,0 +1,2 @@
// This is purposely empty. See src/bench.rs instead. We use src/bench.rs
// to avoid including the same file in multiple build targets.