Skip to content

Commit fd86875

Browse files
committed
test: Gate benchmarks on a feature.
1 parent 9dbbbbf commit fd86875

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ serde = {version = ">=0.6.6, <0.9", optional = true}
2525
[features]
2626
serde-serialization = [ "serde" ]
2727
heap_size = [ "heapsize" ]
28+
bench = []

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![crate_name = "cssparser"]
66
#![crate_type = "rlib"]
77

8-
#![feature(test)]
8+
#![cfg_attr(feature = "bench", feature(test))]
99
#![deny(missing_docs)]
1010

1111
/*!

src/tests.rs

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5+
#[cfg(feature = "bench")]
56
extern crate test;
67

78
use std::borrow::Cow::{self, Borrowed};
@@ -11,6 +12,8 @@ use std::path::Path;
1112
use std::process::Command;
1213
use rustc_serialize::json::{self, Json, ToJson};
1314
use tempdir::TempDir;
15+
16+
#[cfg(feature = "bench")]
1417
use self::test::Bencher;
1518

1619
use encoding::label::encoding_from_whatwg_label;
@@ -579,8 +582,10 @@ impl ToJson for Color {
579582
}
580583
}
581584

585+
#[cfg(feature = "bench")]
582586
const BACKGROUND_IMAGE: &'static str = include_str!("big-data-url.css");
583587

588+
#[cfg(feature = "bench")]
584589
#[bench]
585590
fn unquoted_url(b: &mut Bencher) {
586591
b.iter(|| {

0 commit comments

Comments
 (0)