Remove benchmarks in favor of json-benchmark repo

This commit is contained in:
David Tolnay 2017-01-15 10:16:06 -08:00
parent b99017867c
commit 09bf0247f5
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
8 changed files with 10 additions and 1614 deletions

View File

@ -10,11 +10,6 @@ rust:
- 1.12.0
- beta
matrix:
include:
- rust: nightly
env: BENCH=1
addons:
apt:
packages:
@ -29,16 +24,12 @@ before_script:
script:
- |
if [ -z $BENCH ]; then
(cd json && travis-cargo build) &&
(cd json && travis-cargo --skip 1.8.0 build -- --features preserve_order) &&
(cd json && travis-cargo --only nightly test) &&
(cd json_tests && travis-cargo --skip nightly test -- --features with-syntex --no-default-features) &&
(cd json_tests && travis-cargo --only nightly test -- --features unstable-testing) &&
(cd json && travis-cargo --only stable doc)
else
(cd json_tests && travis-cargo bench)
fi
(cd json && travis-cargo build) &&
(cd json && travis-cargo --skip 1.8.0 build -- --features preserve_order) &&
(cd json && travis-cargo --only nightly test) &&
(cd json_tests && travis-cargo --skip nightly test -- --features with-syntex --no-default-features) &&
(cd json_tests && travis-cargo --only nightly test -- --features unstable-testing) &&
(cd json && travis-cargo --only stable doc)
after_success:
- (cd json_tests && travis-cargo --only stable coveralls --no-sudo)

33
LICENSE
View File

@ -1,33 +0,0 @@
See LICENSE-APACHE and LICENSE-MIT.
----
bench_log is derived from https://github.com/cloudflare/goser, which has the
following license:
Copyright (c) 2013, CloudFlare, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -28,7 +28,3 @@ skeptic = "0.6"
[[test]]
name = "test"
path = "tests/test.rs"
[[bench]]
name = "bench"
path = "benches/bench.rs"

View File

@ -1,22 +0,0 @@
#![cfg_attr(feature = "nightly-testing", feature(plugin))]
#![cfg_attr(feature = "nightly-testing", plugin(clippy))]
#![cfg_attr(not(feature = "with-syntex"), feature(proc_macro))]
#![feature(test)]
#[cfg(not(feature = "with-syntex"))]
#[macro_use]
extern crate serde_derive;
extern crate num_traits;
extern crate rustc_serialize;
extern crate serde;
extern crate serde_json;
extern crate test;
#[cfg(feature = "with-syntex")]
include!(concat!(env!("OUT_DIR"), "/bench.rs"));
#[cfg(not(feature = "with-syntex"))]
include!("bench.rs.in");

View File

@ -1 +0,0 @@
mod bench_log;

View File

@ -1,124 +0,0 @@
use std::{f64, i64, u64};
use test::Bencher;
use serde_json;
#[bench]
fn bench_deserializer_i64(b: &mut Bencher) {
let s = serde_json::to_string(&i64::MIN).unwrap();
b.bytes = s.len() as u64;
b.iter(|| {
let _s: i64 = serde_json::from_str(&s).unwrap();
});
}
#[bench]
fn bench_deserializer_u64(b: &mut Bencher) {
let s = serde_json::to_string(&u64::MAX).unwrap();
b.bytes = s.len() as u64;
b.iter(|| {
let _s: u64 = serde_json::from_str(&s).unwrap();
});
}
#[bench]
fn bench_deserializer_f64_epsilon(b: &mut Bencher) {
let s = serde_json::to_string(&f64::EPSILON).unwrap();
b.bytes = s.len() as u64;
b.iter(|| {
let _s: f64 = serde_json::from_str(&s).unwrap();
});
}
#[bench]
fn bench_deserializer_f64_min(b: &mut Bencher) {
let s = serde_json::to_string(&f64::MIN).unwrap();
b.bytes = s.len() as u64;
b.iter(|| {
let _s: f64 = serde_json::from_str(&s).unwrap();
});
}
#[bench]
fn bench_deserializer_f64_max(b: &mut Bencher) {
let s = "1.7976931348623157e+308";
let s = serde_json::to_string(&f64::MAX).unwrap();
println!("{}", s);
b.bytes = s.len() as u64;
b.iter(|| {
let _s: f64 = serde_json::from_str(&s).unwrap();
});
}
fn make_string(pattern: &str) -> String {
let times = 1000;
let mut s = String::with_capacity(pattern.len() * times + 2);
s.push('"');
for _ in 0..times {
s.push_str(pattern);
}
s.push('"');
s
}
#[bench]
fn bench_deserializer_string(b: &mut Bencher) {
let s = make_string("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456790");
b.bytes = s.len() as u64;
b.iter(|| {
let _s: String = serde_json::from_str(&s).unwrap();
});
}
#[bench]
fn bench_deserializer_escapes(b: &mut Bencher) {
let s = make_string(r"\b\f\n\r\t");
b.bytes = s.len() as u64;
b.iter(|| {
let _s: String = serde_json::from_str(&s).unwrap();
});
}
#[bench]
fn bench_deserializer_unicode(b: &mut Bencher) {
let s = make_string(r"\uD834\uDD1E");
b.bytes = s.len() as u64;
b.iter(|| {
let _s: String = serde_json::from_str(&s).unwrap();
});
}
#[bench]
fn bench_pointer(b: &mut Bencher) {
use serde_json::{self, Value};
let data: Value = serde_json::from_str(r#"{
"foo": ["bar", "baz"],
"": 0,
"a/b": 1,
"c%d": 2,
"e^f": 3,
"g|h": 4,
"i\\j": 5,
"k\"l": 6,
" ": 7,
"m~n": 8
}"#).unwrap();
b.iter(|| {
let _ = data.pointer("").unwrap();
let _ = data.pointer("/foo/0").unwrap();
let _ = data.pointer("/unknown");
});
}

File diff suppressed because it is too large Load Diff

View File

@ -11,16 +11,11 @@ mod with_syntex {
pub fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
for &(src, dst) in &[
("tests/test.rs.in", "test.rs"),
("benches/bench.rs.in", "bench.rs"),
] {
let src = Path::new(src);
let dst = Path::new(&out_dir).join(dst);
let src = Path::new("tests/test.rs.in");
let dst = Path::new(&out_dir).join("test.rs");
serde_codegen::expand(&src, &dst).unwrap();
indoc::expand(&dst, &dst).unwrap();
}
serde_codegen::expand(&src, &dst).unwrap();
indoc::expand(&dst, &dst).unwrap();
}
}