Unverified Commit 7929aed5 authored by Faith Chikwekwe's avatar Faith Chikwekwe Committed by GitHub
Browse files

test: benchmark rust scanner (#3344)



* test: benchmark rust scanner

* feat: added ragel 7 to the Dockerfiles

Installing colm and ragel 7 to /usr/local/ragel7 and putting the bindir on the
path after /usr/local/bin. This hides the ragel version 7 binary, but we only
need the ragel-rust binary.

* fix: add deleted imports
Co-authored-by: default avatarAdrian Thurston <thurston@colm.net>
parent 7c9214e5
......@@ -49,7 +49,7 @@ To build and test the software, the following developer dependencies are require
* Go 1.12 or higher
* Rust
* Ragel 6.10 (only if making changes to the scanner)
* Ragel 7 (only if making changes to the scanner)
Flux follows the standard Go project structure
......
......@@ -15,7 +15,7 @@ RUN apt-get update && \
autoconf automake autotools-dev libtool xutils-dev valgrind && \
rm -rf /var/lib/apt/lists/*
# Download, verify, and install ragel version 6.
# Download, verify, and install ragel version 6.
ENV RAGEL_VERSION=6.10
RUN curl https://www.colm.net/files/thurston.asc | gpg --import - && \
curl https://www.colm.net/files/ragel/ragel-${RAGEL_VERSION}.tar.gz -O && \
......
......@@ -213,9 +213,9 @@ dependencies = [
[[package]]
name = "criterion"
version = "0.3.1"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fc755679c12bda8e5523a71e4d654b6bf2e14bd838dfc48cde6559a05caf7d1"
checksum = "70daa7ceec6cf143990669a04c7df13391d55fb27bd4079d252fca774ba244d8"
dependencies = [
"atty",
"cast",
......@@ -230,6 +230,7 @@ dependencies = [
"rayon",
"regex",
"serde",
"serde_cbor",
"serde_derive",
"serde_json",
"tinytemplate",
......@@ -238,9 +239,9 @@ dependencies = [
[[package]]
name = "criterion-plot"
version = "0.4.1"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a01e15e0ea58e8234f96146b1f91fa9d0e4dd7a38da93ff7a75d42c0b9d3a545"
checksum = "e022feadec601fba1649cfa83586381a4ad31c6bf3a9ab7d408118b05dd9889d"
dependencies = [
"cast",
"itertools",
......@@ -409,6 +410,12 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "half"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d36fab90f82edc3c747f9d438e06cf0a491055896f2a279638bb5beed6c40177"
[[package]]
name = "hermit-abi"
version = "0.1.10"
......@@ -429,9 +436,9 @@ dependencies = [
[[package]]
name = "itertools"
version = "0.8.2"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484"
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
dependencies = [
"either",
]
......@@ -761,6 +768,16 @@ dependencies = [
"serde_json",
]
[[package]]
name = "serde_cbor"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e18acfa2f90e8b735b2836ab8d538de304cbb6729a7360729ea5a895d15a622"
dependencies = [
"half",
"serde",
]
[[package]]
name = "serde_derive"
version = "1.0.106"
......@@ -861,9 +878,9 @@ dependencies = [
[[package]]
name = "tinytemplate"
version = "1.0.3"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57a3c6667d3e65eb1bc3aed6fd14011c6cbc3a0665218ab7f5daf040b9ec371a"
checksum = "6d3dc76004a03cec1c5932bca4cdc2e39aaa798e3f82363dd94f9adf6098c12f"
dependencies = [
"serde",
"serde_json",
......
......@@ -33,4 +33,4 @@ pretty_assertions = "0.6.1"
[build-dependencies]
cc = "1.0"
bindgen = "0.49.0"
bindgen = "0.49.0"
\ No newline at end of file
......@@ -3,6 +3,7 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
pub type CChar = u8;
use crate::fmt;
use std::collections::HashMap;
use std::ffi::CString;
use std::str;
......@@ -44,6 +45,19 @@ pub struct Token {
pub comments: Option<Box<Token>>,
}
// To use the `{}` marker, the trait `fmt::Display` must be implemented
// manually for the type.
impl fmt::Display for Token {
// This trait requires `fmt` with this exact signature.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// Write strictly the first element into the supplied output
// stream: `f`. Returns `fmt::Result` which indicates whether the
// operation succeeded or failed. Note that `write!` uses syntax which
// is very similar to `println!`.
write!(f, "{}", self.lit)
}
}
impl Scanner {
// New creates a scanner with the provided input.
pub fn new(data: CString) -> Scanner {
......
......@@ -19,7 +19,7 @@ wasm-bindgen = { version = "0.2.62", features = ["serde-serialize"] }
[dev-dependencies]
maplit = "1.0.2"
criterion = "0.3.0"
criterion = "0.3.3"
[build-dependencies]
core = { path = "../core" }
......@@ -36,3 +36,8 @@ harness = false
[[bench]]
name = "formatter"
harness = false
[[bench]]
name = "bench_scanner"
path = "benches/benchmarks.rs"
harness = false
This diff is collapsed.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment