Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

[draft] Add simdjson-rust #24

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,22 @@ rustc-serialize = { version = "0.3", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", optional = true }
simd-json = { version = "0.10", optional = true }
simdjson-rust = { version = "0.3.0-alpha.2", optional = true }

[features]
default = ["performance", "all-libs", "all-files"]
all-libs = ["lib-serde", "lib-rustc-serialize", "lib-simd-json"]
all-libs = [
"lib-serde",
# lib-rustc-serialize",
"lib-simd-json",
"lib-simdjson-rust"
]
all-files = ["file-canada", "file-citm-catalog", "file-twitter"]
performance = ["parse-dom", "stringify-dom", "parse-struct", "stringify-struct"]
lib-serde = ["serde", "serde_json"]
lib-simd-json = ["serde", "simd-json"]
lib-rustc-serialize = ["rustc-serialize"]
lib-simdjson-rust = ["simdjson-rust"]
file-canada = []
file-citm-catalog = []
file-twitter = []
Expand Down
40 changes: 40 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,40 @@ macro_rules! bench_file_simd_json {
}
}

#[cfg(feature = "lib-simdjson-rust")]
macro_rules! bench_file_simdjson_rust {
(
path: $path:expr,
structure: $structure:ty,
) => {
let num_trials = num_trials().unwrap_or(256);

print!("{:22}", $path);
io::stdout().flush().unwrap();

let contents = simdjson_rust::padded_string::load_padded_string($path).unwrap();

#[cfg(feature = "parse-dom")]
{
use timer::Benchmark;
let mut benchmark = Benchmark::new();
let mut parser = simdjson_rust::dom::Parser::default();
for _ in 0..num_trials {
let mut timer = benchmark.start();
let _parsed = parser.parse(&contents).unwrap();
timer.stop();
}
let dur = benchmark.min_elapsed();
print!("{:6} MB/s", throughput(dur, contents.len()));
io::stdout().flush().unwrap();
}
#[cfg(not(feature = "parse-dom"))]
print!(" ");

println!();
};
}

fn main() {
print!("{:>35}{:>24}", "DOM", "STRUCT");

Expand Down Expand Up @@ -226,6 +260,12 @@ fn main() {
name: "simd-json",
bench: bench_file_simd_json,
}

#[cfg(feature = "lib-simdjson-rust")]
bench! {
name: "simdjson-rust",
bench: bench_file_simdjson_rust,
}
}

#[cfg(all(
Expand Down