Skip to content

Commit

Permalink
Move benchmarks to an inner crate
Browse files Browse the repository at this point in the history
That's because there are following requirements:
* Tests should work for pre-1.26 and post-1.26 Rust alike;
* Benchmarks depend on 128-bit integer support from Rand.

The issue is that Rand 0.5 supports that via Cargo feature flag, not
`rustc` version detection and `cfg`-dependent feature selection doesn't
work: <rust-lang/cargo#2524>.

A solution is to have a crate just for benchmarking. The directory
structure looks like this because there are plans to use Criterion for
benchmarking on stable and beta Rusts.
  • Loading branch information
hcpl committed Nov 11, 2018
1 parent ac18b59 commit 5d79298
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ matrix:
script:
- cargo test --verbose --all --lib --features "nightly test-nightly-regressions"
- cargo test --verbose --all --tests --features "nightly test-nightly-regressions"
- cargo test --verbose --all --benches --features "nightly test-nightly-regressions"
- which cargo-clippy && cargo clippy --verbose --all --features "nightly test-nightly-regressions"

- cargo test --verbose --all --lib --features "nightly quickcheck test-nightly-regressions"
- cargo test --verbose --all --tests --features "nightly quickcheck test-nightly-regressions"
- cargo test --verbose --all --benches --features "nightly quickcheck test-nightly-regressions"
- which cargo-clippy && cargo clippy --verbose --all --features "nightly quickcheck test-nightly-regressions"

- cargo test --verbose --manifest-path bench-suite/Cargo.toml --all --benches

- cargo update -Z minimal-versions
- cargo build --verbose --manifest-path serde_mtproto_derive/Cargo.toml --lib
- which cargo-clippy && cargo clippy --verbose --manifest-path serde_mtproto_derive/Cargo.toml
Expand Down
9 changes: 2 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ homepage = "https://github.com/hcpl/serde_mtproto"
documentation = "https://docs.rs/serde_mtproto"
repository = "https://github.com/hcpl/serde_mtproto"
keywords = ["serde", "serialization", "telegram"]
include = ["Cargo.toml", "LICENSE-APACHE", "LICENSE-MIT", "README.md", "src/**/*"]

[badges]
travis-ci = { repository = "hcpl/serde_mtproto" }
Expand All @@ -32,23 +33,17 @@ version_check = "0.1"
[dev-dependencies]
derivative = "1.0.2"
lazy_static = "~1.2"
lipsum = "0.5"
maplit = "1.0"
pretty_assertions = "0.5"
#quickcheck_derive = "0.2"
quickcheck_derive = { git = "https://github.com/hcpl/quickcheck_derive", branch = "minimum-supported-rustc" }
rand = "0.5"
serde_json = "1.0"
serde_mtproto_derive = { path = "serde_mtproto_derive", version = "=0.3.1" } # Update in lockstep
serde_yaml = "0.8"
toml = "0.4"
version-sync = "0.5"

[target.'cfg(stable_i128)'.dev-dependencies]
rand = { version = "0.5", features = ["i128_support"] }

[target.'cfg(not(stable_i128))'.dev-dependencies]
rand = "0.5"

[features]
default = []
nightly = []
Expand Down
4 changes: 4 additions & 0 deletions bench-suite/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[workspace]
members = [
"bench-nightly-test",
]
15 changes: 15 additions & 0 deletions bench-suite/bench-nightly-test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "bench-nightly-test"
version = "0.0.0"
description = "Benchmark suite using nightly `test::Bencher`"
authors = ["Nguyen Duc My <hcpl.prog@gmail.com>"]
license = "MIT OR Apache-2.0"
publish = false

[dev-dependencies]
lipsum = "0.5"
rand = "0.5"
serde = "1.0"
serde_derive = "1.0"
serde_mtproto = { path = "../.." }
serde_mtproto_derive = { path = "../../serde_mtproto_derive" }
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion serde_mtproto_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "serde_mtproto_derive"
version = "0.3.1"
description = "Procedural macro helper for serde_mtproto"
authors = ["Nguyen Duc My <hcpl.prog@gmail.com>"]
license = "MIT/Apache-2.0"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/hcpl/serde_mtproto"
documentation = "https://docs.rs/serde_mtproto_derive"
repository = "https://github.com/hcpl/serde_mtproto"
Expand Down

0 comments on commit 5d79298

Please sign in to comment.