diff options
author | Mike Gerwitz <mike.gerwitz@ryansg.com> | 2019-12-04 09:57:08 -0500 |
---|---|---|
committer | Mike Gerwitz <mike.gerwitz@ryansg.com> | 2020-02-24 14:56:28 -0500 |
commit | 0147cb7cb4972405a683fed581533d3508c23a07 (patch) | |
tree | 5243b67f7647d697438b51f6eddddea29ed80eb8 /tamer | |
parent | 0acc21f16f098b2784b1382b82816889d694f91a (diff) | |
download | tame-0147cb7cb4972405a683fed581533d3508c23a07.tar.gz tame-0147cb7cb4972405a683fed581533d3508c23a07.tar.bz2 tame-0147cb7cb4972405a683fed581533d3508c23a07.zip |
Makefile.am (bench): New target
The configure script will determine if nightly is required for running
benchmarks, because `test` is currently an unstable feature.
Diffstat (limited to 'tamer')
-rw-r--r-- | tamer/Cargo.toml | 5 | ||||
-rw-r--r-- | tamer/Makefile.am | 5 | ||||
-rw-r--r-- | tamer/README.md | 17 | ||||
-rw-r--r-- | tamer/build-aux/bench_check.rs | 23 | ||||
-rw-r--r-- | tamer/configure.ac | 10 |
5 files changed, 59 insertions, 1 deletions
diff --git a/tamer/Cargo.toml b/tamer/Cargo.toml index 9880167..406afcb 100644 --- a/tamer/Cargo.toml +++ b/tamer/Cargo.toml @@ -17,6 +17,11 @@ opt-level = 3 [profile.release] lto = true +[profile.bench] +# We want our benchmarks to be representative of how well TAME will perform +# in a release. +lto = true + [dependencies] quick-xml = ">= 0.17.0" petgraph = ">= 0.4.13" diff --git a/tamer/Makefile.am b/tamer/Makefile.am index 3248bc6..8e78117 100644 --- a/tamer/Makefile.am +++ b/tamer/Makefile.am @@ -18,7 +18,7 @@ .DELETE_ON_ERROR: -.PHONY: all fix fmt +.PHONY: all fix fmt check-fmt bench CARGO_BUILD_FLAGS=@CARGO_BUILD_FLAGS@ @@ -37,6 +37,9 @@ check-am: check-fmt check-fmt: @CARGO@ fmt -- --check +bench: + @CARGO@ @CARGO_BENCH_FLAGS@ bench + fix: fmt fmt: @CARGO@ fmt diff --git a/tamer/README.md b/tamer/README.md index 2d14ef4..4f602f0 100644 --- a/tamer/README.md +++ b/tamer/README.md @@ -78,3 +78,20 @@ If you want to automatically fix formatting errors and then run tests: ```sh $ make fmt check ``` + + +## Benchmarking +Benchmarks serve two purposes: external integration tests (which are subject +to module visibility constraints) and actual benchmarking. To run +benchmarks, invoke `make bench`. + +Note that link-time optimizations (LTO) are performed on the binary for +benchmarking so that its performance reflects release builds that will be +used in production. + +The `configure` script will automatically detect whether the `test` feature +is unstable (as it was as of the time of writing) and, if so, will +automatically fall back to invoking nightly (by running `cargo +nightly +bench`). + +If you do not have nightly, run you install it via `rustup install nightly`. diff --git a/tamer/build-aux/bench_check.rs b/tamer/build-aux/bench_check.rs new file mode 100644 index 0000000..ac3d8e6 --- /dev/null +++ b/tamer/build-aux/bench_check.rs @@ -0,0 +1,23 @@ +// Feature check for `test` +// +// Copyright (C) 2014-2019 Ryan Specialty Group, LLC. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. + +// As of the time of writing, this feature is unstable and can only be +// enabled in nightly. This file is intended to be used in the `configure` +// script to determine whether a nightly version of Rust must be used to +// invoke benchmarks. +#![feature(test)] + diff --git a/tamer/configure.ac b/tamer/configure.ac index 350b77b..f2a1bff 100644 --- a/tamer/configure.ac +++ b/tamer/configure.ac @@ -55,6 +55,16 @@ AX_COMPARE_VERSION([$rustc_version], [ge], [$rustc_ver_req], AC_ARG_VAR([CARGO_BUILD_FLAGS], [Flags to be passed to `cargo build' when invoked via Make]) +# The `test` feature is required for benchmarking. If unavailable, then +# it's still an unstable feature and we'll need to use nightly. We don't +# check for nightly here, though---if it's missing, then cargo will tell the +# user what to do. +AC_MSG_CHECKING([`test` feature support]) +AS_IF(["$RUSTC" --crate-type lib build_aux/bench_check.rs &>/dev/null], + [AC_MSG_RESULT(available)], + [AC_MSG_RESULT([no (nightly required)]) + AC_SUBST([CARGO_BENCH_FLAGS], [+nightly])]) + # Cargo commands may be available but not necessarily installed for the # active toolchain. Let's check that. AC_MSG_CHECKING([whether cargo-fmt is available for active toolchain]) |