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

Commit

Permalink
Update simd-json
Browse files Browse the repository at this point in the history
Signed-off-by: Heinz N. Gies <[email protected]>
  • Loading branch information
Licenser committed Oct 23, 2023
1 parent 342987f commit 8cc1153
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ jemallocator = "0.5"
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.7", optional = true }
simd-json-derive = { version = "0.7", optional = true }
time = "0.3"
simd-json = { version = "0.12", optional = true }
simd-json-derive = { version = "0.12", optional = true }

[features]
default = ["performance", "all-libs", "all-files"]
Expand Down
2 changes: 1 addition & 1 deletion src/empty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<'input> simd_json_derive::Deserialize<'input> for Array {
where
Self: std::marker::Sized + 'input,
{
if let Some(simd_json::Node::Array(0, _)) = tape.next() {
if let Some(simd_json::Node::Array { len: 0, .. }) = tape.next() {
Ok(Self)
} else {
Err(simd_json::Error::generic(
Expand Down
21 changes: 9 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ macro_rules! bench_file_simd_json {
} => {

let num_trials = num_trials().unwrap_or(256);
let mut string_buffer = Vec::with_capacity(4096);
let mut input_buffer = simd_json::AlignedBuf::with_capacity(4096);
let mut buffers = simd_json::Buffers::new(4096);

print!("{:22}", $path);
io::stdout().flush().unwrap();
Expand All @@ -153,7 +152,7 @@ macro_rules! bench_file_simd_json {
for _ in 0..num_trials {
data.as_mut_slice().clone_from_slice(contents.as_slice());
let mut timer = benchmark.start();
let _parsed = simd_json_parse_dom(&mut data, &mut input_buffer, &mut string_buffer).unwrap();
let _parsed = simd_json_parse_dom(&mut data, &mut buffers).unwrap();
timer.stop();
}
let dur = benchmark.min_elapsed();
Expand All @@ -167,7 +166,7 @@ macro_rules! bench_file_simd_json {
{
let len = contents.len();
let mut data = contents.clone();
let dom = simd_json_parse_dom(&mut data, &mut input_buffer, &mut string_buffer).unwrap();
let dom = simd_json_parse_dom(&mut data, &mut buffers).unwrap();
let dur = timer::bench_with_buf(num_trials, len, |out| {
simd_json::Writable::write(&dom, out).unwrap()
});
Expand All @@ -187,7 +186,7 @@ macro_rules! bench_file_simd_json {
for _ in 0..num_trials {
data.as_mut_slice().clone_from_slice(contents.as_slice());
let mut timer = benchmark.start();
let _parsed: $structure = simd_json_parse_struct(&mut data, &mut input_buffer, &mut string_buffer).unwrap();
let _parsed: $structure = simd_json_parse_struct(&mut data, &mut buffers).unwrap();
timer.stop();
}
let dur = benchmark.min_elapsed();
Expand All @@ -200,7 +199,7 @@ macro_rules! bench_file_simd_json {
use simd_json_derive::Serialize;
let len = contents.len();
let mut data = contents.clone();
let parsed: $structure = simd_json_parse_struct(&mut data, &mut input_buffer, &mut string_buffer).unwrap();
let parsed: $structure = simd_json_parse_struct(&mut data, &mut buffers).unwrap();
let dur = timer::bench_with_buf(num_trials, len, |out| {
parsed.json_write(out).unwrap();
});
Expand Down Expand Up @@ -313,10 +312,9 @@ where
))]
fn simd_json_parse_dom<'input>(
bytes: &'input mut [u8],
input_buffer: &mut simd_json::AlignedBuf,
string_buffer: &mut [u8],
buffers: &mut simd_json::Buffers,
) -> simd_json::Result<simd_json::BorrowedValue<'input>> {
simd_json::to_borrowed_value_with_buffers(bytes, input_buffer, string_buffer)
simd_json::to_borrowed_value_with_buffers(bytes, buffers)
}

// #[cfg(all(
Expand All @@ -336,11 +334,10 @@ fn simd_json_parse_dom<'input>(
))]
fn simd_json_parse_struct<'de, T>(
bytes: &'de mut [u8],
input_buffer: &mut simd_json::AlignedBuf,
string_buffer: &mut [u8],
buffers: &mut simd_json::Buffers,
) -> simd_json::Result<T>
where
T: simd_json_derive::Deserialize<'de> + 'de,
{
T::from_slice_with_buffers(bytes, input_buffer, string_buffer)
T::from_slice_with_buffers(bytes, buffers)
}

0 comments on commit 8cc1153

Please sign in to comment.