Skip to content

Commit e39346e

Browse files
committed
Move benchmarks to a separate crate
1 parent 1b25e47 commit e39346e

File tree

7 files changed

+33
-16
lines changed

7 files changed

+33
-16
lines changed

.github/workflows/lint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ jobs:
1717
- uses: Swatinem/rust-cache@v2
1818
- run: cargo fmt --check -- --color=always
1919
- run: cargo fmt --check --manifest-path fuzz/Cargo.toml
20+
- run: cargo fmt --check --manifest-path bench/Cargo.toml
2021
- run: |
2122
cargo clippy --all-features --all-targets --color=always \
2223
-- -D warnings
2324
- run: |
2425
cargo clippy --manifest-path fuzz/Cargo.toml --color=always \
2526
-- -D warnings
27+
- run: |
28+
cargo clippy --manifest-path bench/Cargo.toml --color=always \
29+
-- -D warnings
2630
env:
2731
RUSTFLAGS: "-Dwarnings"
2832

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
with:
5858
toolchain: ${{ matrix.rust_version }}
5959
- uses: Swatinem/rust-cache@v2
60-
- run: cargo check --benches
60+
- run: cargo check --manifest-path bench/Cargo.toml --benches
6161
- run: cargo check --manifest-path fuzz/Cargo.toml --all-targets
6262
# run --lib and --doc to avoid the long running integration tests
6363
# which are run elsewhere

Cargo.toml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ clock = ["std", "winapi", "iana-time-zone", "android-tzdata"]
2626
oldtime = ["time"]
2727
wasmbind = ["wasm-bindgen", "js-sys"]
2828
unstable-locales = ["pure-rust-locales", "alloc"]
29-
__internal_bench = ["criterion"]
29+
__internal_bench = []
3030
__doctest = []
3131

3232
[dependencies]
@@ -35,7 +35,6 @@ num-traits = { version = "0.2", default-features = false }
3535
rustc-serialize = { version = "0.3.20", optional = true }
3636
serde = { version = "1.0.99", default-features = false, optional = true }
3737
pure-rust-locales = { version = "0.6", optional = true }
38-
criterion = { version = "0.4.0", optional = true }
3938
rkyv = { version = "0.7", optional = true }
4039
arbitrary = { version = "1.0.0", features = ["derive"], optional = true }
4140

@@ -71,13 +70,3 @@ rustdoc-args = ["--cfg", "docsrs"]
7170

7271
[package.metadata.playground]
7372
features = ["serde"]
74-
75-
[[bench]]
76-
name = "chrono"
77-
required-features = ["__internal_bench"]
78-
harness = false
79-
80-
[[bench]]
81-
name = "serde"
82-
required-features = ["__internal_bench", "serde"]
83-
harness = false

bench/Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[package]
2+
name = "benches"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# Even as a `dev-dependency` Criterion and its dependencies can affect the MSRV of chrono.
7+
# But not when it lives in a separate crate :-).
8+
# See https://github.com/chronotope/chrono/pull/1104.
9+
10+
[lib]
11+
name = "benches"
12+
13+
[dependencies]
14+
chrono = { path = "..", features = ["__internal_bench", "serde"] }
15+
16+
[[bench]]
17+
name = "chrono"
18+
harness = false
19+
20+
[[bench]]
21+
name = "serde"
22+
harness = false
23+
24+
[dev-dependencies]
25+
criterion = "0.5.0"
26+
serde_json = "1"

benches/chrono.rs renamed to bench/benches/chrono.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//! Benchmarks for chrono that just depend on std
2-
#![cfg(feature = "__internal_bench")]
32
43
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
54

benches/serde.rs renamed to bench/benches/serde.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(feature = "__internal_bench")]
2-
31
use criterion::{black_box, criterion_group, criterion_main, Criterion};
42

53
use chrono::NaiveDateTime;

bench/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This file only exists to make `benches` a valid crate.

0 commit comments

Comments
 (0)