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

Commit 4ff8d66

Browse files
committed
Remove bench_simd_json macro
1 parent 2997049 commit 4ff8d66

File tree

1 file changed

+15
-40
lines changed

1 file changed

+15
-40
lines changed

src/main.rs

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,60 +9,35 @@ use std::io::{self, Read, Write};
99
macro_rules! bench {
1010
{
1111
name: $name:expr,
12+
bench: $bench:ident,
1213
$($args:tt)*
1314
} => {
1415
let name = format!(" {} ", $name);
1516
println!("\n{:=^26} parse|stringify ===== parse|stringify ====", name);
1617

1718
#[cfg(feature = "file-canada")]
18-
bench_file! {
19+
$bench! {
1920
path: "data/canada.json",
2021
structure: canada::Canada,
2122
$($args)*
2223
}
2324

2425
#[cfg(feature = "file-citm-catalog")]
25-
bench_file! {
26+
$bench! {
2627
path: "data/citm_catalog.json",
2728
structure: citm_catalog::CitmCatalog,
2829
$($args)*
2930
}
3031

3132
#[cfg(feature = "file-twitter")]
32-
bench_file! {
33+
$bench! {
3334
path: "data/twitter.json",
3435
structure: twitter::Twitter,
3536
$($args)*
3637
}
3738
}
3839
}
3940

40-
#[cfg(feature = "lib-simd-json")]
41-
macro_rules! bench_simd_json {
42-
{} => {
43-
let name = format!(" simd_json ");
44-
println!("\n{:=^26} parse|stringify ===== parse|stringify ====", name);
45-
46-
#[cfg(feature = "file-canada")]
47-
bench_file_simd_json! {
48-
path: "data/canada.json",
49-
structure: canada::Canada,
50-
}
51-
52-
#[cfg(feature = "file-citm-catalog")]
53-
bench_file_simd_json! {
54-
path: "data/citm_catalog.json",
55-
structure: citm_catalog::CitmCatalog,
56-
}
57-
58-
#[cfg(feature = "file-twitter")]
59-
bench_file_simd_json! {
60-
path: "data/twitter.json",
61-
structure: twitter::Twitter,
62-
}
63-
}
64-
}
65-
6641
macro_rules! bench_file {
6742
{
6843
path: $path:expr,
@@ -144,6 +119,10 @@ macro_rules! bench_file {
144119
}
145120
}
146121

122+
// This library is handled separately because simd-json needs to mutate its
123+
// input unlike the other libraries. While this makes little difference in a
124+
// real life situation as you're unlikely to deserialize the same data twice,
125+
// it can be a disadvantage in a benchmark.
147126
#[cfg(feature = "lib-simd-json")]
148127
macro_rules! bench_file_simd_json {
149128
{
@@ -241,6 +220,7 @@ fn main() {
241220
#[cfg(feature = "lib-serde")]
242221
bench! {
243222
name: "serde_json",
223+
bench: bench_file,
244224
dom: serde_json::Value,
245225
parse_dom: serde_json_parse_dom,
246226
stringify_dom: serde_json::to_writer,
@@ -251,6 +231,7 @@ fn main() {
251231
#[cfg(feature = "lib-json-rust")]
252232
bench! {
253233
name: "json-rust",
234+
bench: bench_file,
254235
dom: json::JsonValue,
255236
parse_dom: json_rust_parse_dom,
256237
stringify_dom: json_rust_stringify_dom,
@@ -259,25 +240,19 @@ fn main() {
259240
#[cfg(feature = "lib-rustc-serialize")]
260241
bench! {
261242
name: "rustc_serialize",
243+
bench: bench_file,
262244
dom: rustc_serialize::json::Json,
263245
parse_dom: rustc_serialize_parse_dom,
264246
stringify_dom: rustc_serialize_stringify,
265247
parse_struct: rustc_serialize_parse_struct,
266248
stringify_struct: rustc_serialize_stringify,
267249
}
268250

269-
// This is rolled out since simd-json does mutate
270-
// its input unlike the other libraries.
271-
// While this makes little difference in a real life situation
272-
// as you're unlikely to deserialize the same data twice
273-
// it is a big disadvantage in a synthetic benchmark.
274-
//
275-
// To be fair to both other libraries and simd-json
276-
// we roll it out and provide the same benchmarks
277-
// with slightly different characteristics.
278-
279251
#[cfg(feature = "lib-simd-json")]
280-
bench_simd_json! {}
252+
bench! {
253+
name: "simd_json",
254+
bench: bench_file_simd_json,
255+
}
281256
}
282257

283258
#[cfg(all(

0 commit comments

Comments
 (0)