Makefile.am (bench): New target

The configure script will determine if nightly is required for running
benchmarks, because `test` is currently an unstable feature.
master
Mike Gerwitz 2019-12-04 09:57:08 -05:00
parent 0acc21f16f
commit 0147cb7cb4
5 changed files with 59 additions and 1 deletions

View File

@ -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"

View File

@ -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

View File

@ -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`.

View File

@ -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)]

View File

@ -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])