From f0d518231c69b2960ccec5edb26792027577cfb3 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 2 Jul 2019 08:22:03 +0200 Subject: [PATCH 1/4] Move benchmarks into its own crate --- Cargo.toml | 3 +-- README.md | 6 ++++-- ci/run.sh | 14 +++++++++----- crates/libm-bench/Cargo.toml | 11 +++++++++++ {benches => crates/libm-bench/benches}/bench.rs | 3 --- 5 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 crates/libm-bench/Cargo.toml rename {benches => crates/libm-bench/benches}/bench.rs (98%) diff --git a/Cargo.toml b/Cargo.toml index 2f68ecc..bd1bb80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,12 +26,11 @@ checked = [] [workspace] members = [ "crates/compiler-builtins-smoke-test", + "crates/libm-bench", ] [dev-dependencies] no-panic = "0.1.8" -rand = "0.6.5" -paste = "0.1.5" [build-dependencies] rand = { version = "0.6.5", optional = true } diff --git a/README.md b/README.md index edd54d4..8b93f26 100644 --- a/README.md +++ b/README.md @@ -39,9 +39,11 @@ The API documentation can be found [here](https://docs.rs/libm). ## Benchmark [benchmark]: #benchmark -Run `cargo +nightly bench` -NOTE: remember to have nightly installed `rustup install nightly` +The benchmarks are located in `crates/libm-bench` and require a nightly Rust toolchain. +To run all benchmarks: + +> cargo +nightly bench --all ## Contributing diff --git a/ci/run.sh b/ci/run.sh index 42c2416..37ffb87 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -1,11 +1,15 @@ -#!/bin/sh +#!/usr/bin/env sh set -ex TARGET=$1 -cargo test --target $TARGET -cargo test --target $TARGET --release +CMD="cargo test --all --no-default-features --target $TARGET" -cargo test --features 'checked musl-reference-tests' --target $TARGET +$CMD +$CMD --release -cargo test --features 'checked musl-reference-tests' --target $TARGET --release +$CMD --features 'stable' +$CMD --release --features 'stable' + +$CMD --features 'stable checked musl-reference-tests' +$CMD --release --features 'stable checked musl-reference-tests' diff --git a/crates/libm-bench/Cargo.toml b/crates/libm-bench/Cargo.toml new file mode 100644 index 0000000..8e06e0f --- /dev/null +++ b/crates/libm-bench/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "libm-bench" +version = "0.1.0" +authors = ["Gonzalo Brito Gadeschi "] +edition = "2018" +license = "MIT OR Apache-2.0" + +[dependencies] +libm = { path = "../.." } +rand = "0.6.5" +paste = "0.1.5" diff --git a/benches/bench.rs b/crates/libm-bench/benches/bench.rs similarity index 98% rename from benches/bench.rs rename to crates/libm-bench/benches/bench.rs index 522ac4e..b6d8741 100644 --- a/benches/bench.rs +++ b/crates/libm-bench/benches/bench.rs @@ -1,7 +1,4 @@ #![feature(test)] - -extern crate paste; -extern crate rand; extern crate test; use rand::Rng; From 8f018d633c7bf36ea4cd552fa4b8f89d6a453584 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 2 Jul 2019 08:32:31 +0200 Subject: [PATCH 2/4] Do not enable default features in benchmarks --- crates/libm-bench/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/libm-bench/Cargo.toml b/crates/libm-bench/Cargo.toml index 8e06e0f..d28dd86 100644 --- a/crates/libm-bench/Cargo.toml +++ b/crates/libm-bench/Cargo.toml @@ -6,6 +6,6 @@ edition = "2018" license = "MIT OR Apache-2.0" [dependencies] -libm = { path = "../.." } +libm = { path = "../..", default-features = false } rand = "0.6.5" paste = "0.1.5" From 407b8b74ca0787aba02596b9f5eae98a86e016a9 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 2 Jul 2019 08:33:11 +0200 Subject: [PATCH 3/4] Re-export the stable libm feature --- crates/libm-bench/Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/libm-bench/Cargo.toml b/crates/libm-bench/Cargo.toml index d28dd86..ba65dbd 100644 --- a/crates/libm-bench/Cargo.toml +++ b/crates/libm-bench/Cargo.toml @@ -9,3 +9,7 @@ license = "MIT OR Apache-2.0" libm = { path = "../..", default-features = false } rand = "0.6.5" paste = "0.1.5" + +[features] +default = [] +stable = [ "libm/stable" ] From ab7089bbe29f58c6dac41ca946f059ed23e48dc7 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 2 Jul 2019 09:07:10 +0200 Subject: [PATCH 4/4] Run benchmarks on CI --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e9cb916..c89346c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -77,7 +77,7 @@ jobs: vmImage: ubuntu-16.04 steps: - template: ci/azure-install-rust.yml - - bash: cargo bench + - bash: cargo bench --all displayName: "Benchmarks" variables: TOOLCHAIN: nightly