Compare commits

..
Author SHA1 Message Date
sharkdp 148460b950 Fix nan/inf output for very fast commands
closes #319
2020-10-16 10:50:52 +02:00
17 changed files with 151 additions and 360 deletions

No files matched your search

-8
View File
@@ -1,8 +0,0 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: monthly
time: "04:00"
timezone: Europe/Berlin
+12 -17
View File
@@ -1,5 +1,6 @@
language: rust
jobs:
cache: cargo
matrix:
include:
# Stable channel.
- os: linux
@@ -17,17 +18,6 @@ jobs:
- os: osx
rust: stable
env: TARGET=x86_64-apple-darwin
- os: linux
rust: stable
env:
- TARGET=arm-unknown-linux-gnueabihf
- CC_arm_unknown_linux_gnueabihf=/usr/bin/arm-linux-gnueabihf-gcc-4.8
- CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc-4.8
- os: linux
rust: stable
env:
- TARGET=arm-unknown-linux-musleabihf
- CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_LINKER=arm-linux-gnueabihf-gcc-4.8
# Minimum Rust supported channel.
- os: linux
@@ -46,8 +36,13 @@ jobs:
rust: 1.43.0
env: TARGET=x86_64-apple-darwin
before_install:
- ci/before_install.bash
addons:
apt:
packages:
# needed for i686-unknown-linux-gnu target
- gcc-multilib
# needed to build deb packages
- fakeroot
env:
global:
@@ -64,19 +59,19 @@ install:
script:
# Incorporate TARGET env var to the build and test process
- cargo build --target $TARGET --verbose
- '[[ $TARGET == arm-unknown-linux-* ]] || cargo test --target $TARGET --verbose'
- cargo test --target $TARGET --verbose
before_deploy:
- bash ci/before_deploy.bash
deploy:
provider: releases
# NOTE updating the `token.secure`
# NOTE updating the `api_key.secure`
# - go to: https://github.com/settings/tokens/new
# - generate new token using `public_repo` scope
# - encrypt it using: `travis encrypt API_KEY_HERE`
# - paste the output below
token:
api_key:
secure: "U9QfCOQkeozaDNrTV6i2vRocX2puB5p1WSN+w9t/1j33rAtXx6ZhFx67A8nl0+dQ9nvPu/RIsFWXrYzfHQskL1WulKNHm0S5otN+747dEzbSIfMNi1UfysyCiM1SNPq+FX3qOkva83+Fe2Lyd1g4gQObceE4xsgfplfzdm+ebIa6CrfKOypToEuetzP/r8V0WpW4Cp8ojQwvsL1nfHjr1gmvmr443Gr9Yvgq9SS/NAHldrpaJr8mD26W/7jbHdm3lvrNwqLbthYDUTPZsO+2B44h+T/tuhVYbur4fel1KMo4mkIwZwsSKvJbf3Q6Vdcc9dZM+niZU78UGLt0JNEMQNqQLPGYqh+TlFR2B++lcYlybT3LcUaSkt0YIX7C4DAbMLS6sl5Fq2pRNuM/eY2BWdHf0I+K19PDxUEliUifsfSQ3rbfl52aKKLcJa0WPyDJt0qldElagxOaTIk/jn1kKkdkQu9M4gVzKXImIauRQih3CLER7th8ADMxW5Plgq8fvffJBTKlubUznKrGeeR3Mjm8DsRjhkIvFO0Doqmki4sd5zE/BOFI5a/SHg73ms+bLXLuKFK+YzIlHszCHolzkAT44aq7+LEudk8jt+QVtBEocCN/4ew4Q9Qh2tcn22+hU3Aw88lO95PsbZzTzoFtX4X89Sl1fGtpkHFZvvL4ZT0="
# for uploading multiple files
file_glob: true
+6 -30
View File
@@ -1,30 +1,8 @@
# unreleased
- Add command exit code to output if it fails, see #342 (@KaindlJulian)
## Features
## Changes
- When `--export-*` commands are used, result files are created before benchmark execution
to fail early in case of, e.g., wrong permissions. See #306 (@s1ck).
- When `--export-*` options are used, result files are written after each individual
benchmark command instead of writing after all benchmarks have finished. See #306 (@s1ck).
## Bugfixes
## Other
## Packaging
# v1.11.0
## Features
- The `-L`/`--parameter-list` option can now be specified multiple times to
evaluate all possible combinations of the listed parameters:
- The `-L`/`--parameter-list` option can now be specified multiple times to evaluate all possible combinations of the listed parameters:
``` bash
hyperfine -L number 1,2 -L letter a,b,c \
@@ -40,20 +18,18 @@
## Changes
- When parameters are used with `--parameter-list` or `--parameter-scan`, the JSON export format
now contains a dictionary `parameters` instead of a single key `parameter`. See #253, #318.
- The `plot_parametrized.py` script now infers the parameter name, and its `--parameter-name`
argument has been deprecated. See #253, #318.
- When parameters are used with `--parameter-list` or `--parameter-scan`, the JSON export format now contains a dictionary `parameters` instead of a single key `parameter`. See #253, #318.
- The `plot_parametrized.py` script now infers the parameter name, and its `--parameter-name` argument has been deprecated. See #253, #318.
## Bugfixes
- Fix a bug in the outlier detection which would only detect "slow outliers" but not the fast
ones (runs that are much faster than the rest of the benchmarking runs), see #329
- Fix a bug in the outlier detection which would only detect "slow outliers" but not the fast ones (runs that are much faster than the rest of the benchmarking runs), see #329
- Better error messages for very fast commands that would lead to inf/nan results in the relative
speed comparison, see #319
- Show error message if `--warmup` or `--*runs` arguments can not be parsed, see #337
- Keep output colorized when the output is not interactive and `--style=full` or `--style=color` is used.
## Other
## Packaging
# v1.10.0
Generated
+76 -88
View File
@@ -11,19 +11,13 @@ dependencies = [
[[package]]
name = "approx"
version = "0.4.0"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f2a05fd1bd10b2527e20a2cd32d8873d115b8b39fe219ee25f42a8aca6ba278"
checksum = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3"
dependencies = [
"num-traits",
]
[[package]]
name = "arrayvec"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]]
name = "atty"
version = "0.2.14"
@@ -43,9 +37,9 @@ checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2"
[[package]]
name = "autocfg"
version = "1.0.1"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d"
[[package]]
name = "bitflags"
@@ -77,12 +71,6 @@ version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "2.33.3"
@@ -121,9 +109,9 @@ dependencies = [
[[package]]
name = "console"
version = "0.12.0"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0b1aacfaffdbff75be81c15a399b4bedf78aaefe840e8af1d299ac2ade885d2"
checksum = "8c0994e656bba7b922d8dd1245db90672ffb701e684e45be58f20719d69abc5a"
dependencies = [
"encode_unicode",
"lazy_static",
@@ -138,9 +126,9 @@ dependencies = [
[[package]]
name = "csv"
version = "1.1.5"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d58633299b24b515ac72a3f869f8b91306a3cec616a602843a383acd6f9e97"
checksum = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279"
dependencies = [
"bstr",
"csv-core",
@@ -172,37 +160,37 @@ checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[package]]
name = "getrandom"
version = "0.2.0"
version = "0.1.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee8025cf36f917e6a52cce185b7c7177689b838b7ec138364e50cc2277a56cf4"
checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
dependencies = [
"cfg-if 0.1.10",
"cfg-if",
"libc",
"wasi",
]
[[package]]
name = "hermit-abi"
version = "0.1.17"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
checksum = "91780f809e750b0a89f5544be56617ff6b1227ee485bcb06ebe10cdf89bd3b71"
dependencies = [
"libc",
]
[[package]]
name = "hyperfine"
version = "1.11.0"
version = "1.10.0"
dependencies = [
"approx",
"atty",
"cfg-if 1.0.0",
"cfg-if",
"clap",
"colored",
"csv",
"indicatif",
"libc",
"rand 0.8.3",
"rand 0.7.3",
"rust_decimal",
"serde",
"serde_json",
@@ -225,9 +213,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "0.4.6"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
checksum = "b8b7a7c0c47db5545ed3fef7468ee7bb5b74691498139e4b3f6a20685dc6dd8e"
[[package]]
name = "lazy_static"
@@ -237,9 +225,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.86"
version = "0.2.77"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
checksum = "f2f96b10ec2560088a8e76961b00d47107b3a625fecb76dedb29ee7ccbf98235"
[[package]]
name = "memchr"
@@ -267,7 +255,7 @@ version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304"
dependencies = [
"autocfg 1.0.1",
"autocfg 1.0.0",
"num-integer",
"num-traits",
]
@@ -278,27 +266,27 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95"
dependencies = [
"autocfg 1.0.1",
"autocfg 1.0.0",
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.43"
version = "0.1.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d59457e662d541ba17869cf51cf177c0b5f0cbf476c66bdc90bf1edac4f875b"
checksum = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba"
dependencies = [
"autocfg 1.0.1",
"autocfg 1.0.0",
"num-traits",
]
[[package]]
name = "num-iter"
version = "0.1.41"
version = "0.1.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6e6b7c748f995c4c29c5f5ae0248536e04a5739927c74ec0fa564805094b9f"
checksum = "dfb0800a0291891dd9f4fe7bd9c19384f98f7fbe0cd0f39a2c6b88b9868bbc00"
dependencies = [
"autocfg 1.0.1",
"autocfg 1.0.0",
"num-integer",
"num-traits",
]
@@ -309,7 +297,7 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef"
dependencies = [
"autocfg 1.0.1",
"autocfg 1.0.0",
"num-bigint",
"num-integer",
"num-traits",
@@ -317,11 +305,11 @@ dependencies = [
[[package]]
name = "num-traits"
version = "0.2.12"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611"
checksum = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096"
dependencies = [
"autocfg 1.0.1",
"autocfg 1.0.0",
]
[[package]]
@@ -332,24 +320,24 @@ checksum = "17b02fc0ff9a9e4b35b3342880f48e896ebf69f2967921fe8646bf5b7125956a"
[[package]]
name = "ppv-lite86"
version = "0.2.9"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c36fa947111f5c62a733b652544dd0016a43ce89619538a8ef92724a6f501a20"
checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
[[package]]
name = "proc-macro2"
version = "1.0.24"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
checksum = "1502d12e458c49a4c9cbff560d0fe0060c252bc29799ed94ca2ed4bb665a0101"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.7"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
checksum = "54a21852a652ad6f610c9510194f398ff6f8692e334fd1145fed931f7fbe44ea"
dependencies = [
"proc-macro2",
]
@@ -375,14 +363,15 @@ dependencies = [
[[package]]
name = "rand"
version = "0.8.3"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [
"getrandom",
"libc",
"rand_chacha 0.3.0",
"rand_core 0.6.0",
"rand_hc 0.3.0",
"rand_chacha 0.2.2",
"rand_core 0.5.1",
"rand_hc 0.2.0",
]
[[package]]
@@ -397,12 +386,12 @@ dependencies = [
[[package]]
name = "rand_chacha"
version = "0.3.0"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
dependencies = [
"ppv-lite86",
"rand_core 0.6.0",
"rand_core 0.5.1",
]
[[package]]
@@ -422,9 +411,9 @@ checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
name = "rand_core"
version = "0.6.0"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8b34ba8cfb21243bd8df91854c830ff0d785fff2e82ebd4434c2644cb9ada18"
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
dependencies = [
"getrandom",
]
@@ -440,11 +429,11 @@ dependencies = [
[[package]]
name = "rand_hc"
version = "0.3.0"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
dependencies = [
"rand_core 0.6.0",
"rand_core 0.5.1",
]
[[package]]
@@ -511,9 +500,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.4.1"
version = "1.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8963b85b8ce3074fecffde43b4b0dded83ce2f367dc8d363afc56679f3ee820b"
checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692"
dependencies = [
"regex-syntax",
]
@@ -529,41 +518,40 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.6.20"
version = "0.6.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cab7a364d15cde1e505267766a2d3c4e22a843e1a601f0fa7564c0f82ced11c"
checksum = "7fe5bd57d1d7414c6b5ed48563a2c855d995ff777729dcd91c369ec7fea395ae"
[[package]]
name = "rust_decimal"
version = "1.10.3"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc7f5b8840fb1f83869a3e1dfd06d93db79ea05311ac5b42b8337d3371caa4f1"
checksum = "c9e81662973c7a8d9663e64a0de4cd642b89a21d64966e3d99606efdc5fb0cc6"
dependencies = [
"arrayvec",
"num-traits",
"serde",
]
[[package]]
name = "ryu"
version = "1.0.5"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
checksum = "ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1"
[[package]]
name = "serde"
version = "1.0.123"
version = "1.0.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae"
checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.123"
version = "1.0.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9391c295d64fc0abb2c556bad848f33cb8296276b1ad2677d1ae1ace4f258f31"
checksum = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8"
dependencies = [
"proc-macro2",
"quote",
@@ -572,9 +560,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.64"
version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
checksum = "a230ea9107ca2220eea9d46de97eddcb04cd00e92d13dda78e478dd33fa82bd4"
dependencies = [
"itoa",
"ryu",
@@ -599,9 +587,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "syn"
version = "1.0.60"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd"
dependencies = [
"proc-macro2",
"quote",
@@ -620,9 +608,9 @@ dependencies = [
[[package]]
name = "terminal_size"
version = "0.1.13"
version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a14cd9f8c72704232f0bfc8455c0e861f0ad4eb60cc9ec8a170e231414c1e13"
checksum = "8038f95fc7a6f351163f4b964af631bd26c9e828f7db085f2a84aca56f70d13b"
dependencies = [
"libc",
"winapi",
@@ -630,9 +618,9 @@ dependencies = [
[[package]]
name = "termios"
version = "0.3.3"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b"
checksum = "6f0fcee7b24a25675de40d5bb4de6e41b0df07bc9856295e7e2b3a3600c400c2"
dependencies = [
"libc",
]
@@ -649,15 +637,15 @@ dependencies = [
[[package]]
name = "unicode-width"
version = "0.1.8"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
checksum = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479"
[[package]]
name = "unicode-xid"
version = "0.2.1"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
[[package]]
name = "vec_map"
+6 -6
View File
@@ -7,7 +7,7 @@ license = "MIT/Apache-2.0"
name = "hyperfine"
readme = "README.md"
repository = "https://github.com/sharkdp/hyperfine"
version = "1.11.0"
version = "1.10.0"
edition = "2018"
build = "build.rs"
@@ -16,12 +16,12 @@ colored = "2.0"
indicatif = "0.15"
statistical = "1.0"
atty = "0.2"
cfg-if = "1.0"
csv = "1.1.5"
cfg-if = "0.1"
csv = "1.1.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
rust_decimal = "1.10"
rand = "0.8"
rust_decimal = "1.8"
rand = "0.7"
[target.'cfg(not(windows))'.dependencies]
libc = "0.2"
@@ -35,7 +35,7 @@ default-features = false
features = ["suggestions", "color", "wrap_help"]
[dev-dependencies]
approx = "0.4"
approx = "0.3"
[build-dependencies]
clap = "2"
+3 -23
View File
@@ -77,26 +77,6 @@ hyperfine --parameter-scan delay 0.3 0.7 -D 0.2 'sleep {delay}'
```
This runs `sleep 0.3`, `sleep 0.5` and `sleep 0.7`.
### Shell functions and aliases
If you are using bash, you can export shell functions to directly benchmark them with hyperfine:
```
$ my_function() { sleep 1; }
$ export -f my_function
$ hyperfine my_function
```
If you are using a different shell, or if you want to benchmark shell aliases, you may try to put
them in a separate file:
```bash
echo 'my_function() { sleep 1 }' > /tmp/my_function.sh
echo 'alias my_alias="sleep 1"' > /tmp/my_alias.sh
hyperfine 'source /tmp/my_function.sh; eval my_function'
hyperfine 'source /tmp/my_alias.sh; eval my_alias'
```
### Export results
Hyperfine has multiple options for exporting benchmark results: CSV, JSON, Markdown (see `--help`
@@ -121,8 +101,8 @@ The JSON output is useful if you want to analyze the benchmark results in more d
Download the appropriate `.deb` package from the [Release page](https://github.com/sharkdp/hyperfine/releases)
and install it via `dpkg`:
```
wget https://github.com/sharkdp/hyperfine/releases/download/v1.11.0/hyperfine_1.11.0_amd64.deb
sudo dpkg -i hyperfine_1.11.0_amd64.deb
wget https://github.com/sharkdp/hyperfine/releases/download/v1.10.0/hyperfine_1.10.0_amd64.deb
sudo dpkg -i hyperfine_1.10.0_amd64.deb
```
### On Fedora
@@ -211,7 +191,7 @@ Download the corresponding archive from the [Release page](https://github.com/sh
## Alternative tools
Hyperfine is inspired by [bench](https://github.com/Gabriel439/bench).
## Integration with other tools
[Chronologer](https://github.com/dandavison/chronologer) is a tool that uses `hyperfine` to
+6 -64
View File
@@ -11,25 +11,17 @@ pack() {
local tempdir
local out_dir
local package_name
local gcc_prefix
tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
out_dir=$(pwd)
package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET"
if [[ $TARGET == arm-unknown-linux-* ]]; then
gcc_prefix="arm-linux-gnueabihf-"
else
gcc_prefix=""
fi
# create a "staging" directory
mkdir "$tempdir/$package_name"
mkdir "$tempdir/$package_name/autocomplete"
# copying the main binary
cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/"
"${gcc_prefix}"strip "$tempdir/$package_name/$PROJECT_NAME"
strip "$tempdir/$package_name/$PROJECT_NAME"
# manpage, readme and license
cp "doc/$PROJECT_NAME.1" "$tempdir/$package_name"
@@ -38,6 +30,7 @@ pack() {
cp LICENSE-APACHE "$tempdir/$package_name"
# various autocomplete
mkdir "$tempdir/$package_name/autocomplete"
cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".bash "$tempdir/$package_name/autocomplete/${PROJECT_NAME}.bash-completion"
cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/"$PROJECT_NAME".fish "$tempdir/$package_name/autocomplete"
cp target/"$TARGET"/release/build/"$PROJECT_NAME"-*/out/_"$PROJECT_NAME" "$tempdir/$package_name/autocomplete"
@@ -55,29 +48,17 @@ make_deb() {
local version
local dpkgname
local conflictname
local homepage
local maintainer
local gcc_prefix
homepage="https://github.com/sharkdp/$PROJECT_NAME"
maintainer="David Peter <mail@david-peter.de>"
case $TARGET in
x86_64*)
architecture=amd64
gcc_prefix=""
;;
i686*)
architecture=i386
gcc_prefix=""
;;
arm*hf)
architecture=armhf
gcc_prefix="arm-linux-gnueabihf-"
;;
*)
echo "make_deb: skipping target '${TARGET}'" >&2
return 0
echo "ERROR: unknown target" >&2
return 1
;;
esac
version=${TRAVIS_TAG#v}
@@ -93,7 +74,7 @@ make_deb() {
# copy the main binary
install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME"
"${gcc_prefix}"strip "$tempdir/usr/bin/$PROJECT_NAME"
strip "$tempdir/usr/bin/$PROJECT_NAME"
# manpage
install -Dm644 "doc/$PROJECT_NAME.1" "$tempdir/usr/share/man/man1/$PROJECT_NAME.1"
@@ -103,44 +84,6 @@ make_deb() {
install -Dm644 README.md "$tempdir/usr/share/doc/$PROJECT_NAME/README.md"
install -Dm644 LICENSE-MIT "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-MIT"
install -Dm644 LICENSE-APACHE "$tempdir/usr/share/doc/$PROJECT_NAME/LICENSE-APACHE"
cat > "$tempdir/usr/share/doc/$PROJECT_NAME/copyright" <<EOF
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: $PROJECT_NAME
Source: $homepage
Files: *
Copyright: $maintainer
License: Apache-2.0 or MIT
License: Apache-2.0
On Debian systems, the complete text of the Apache-2.0 can be found in the
file /usr/share/common-licenses/Apache-2.0.
License: MIT
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the
Software without restriction, including without
limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software
is furnished to do so, subject to the following
conditions:
.
The above copyright notice and this permission notice
shall be included in all copies or substantial portions
of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
EOF
# completions
install -Dm644 target/$TARGET/release/build/$PROJECT_NAME-*/out/$PROJECT_NAME.bash "$tempdir/usr/share/bash-completion/completions/${PROJECT_NAME}"
@@ -154,11 +97,10 @@ Package: $dpkgname
Version: $version
Section: utils
Priority: optional
Maintainer: $maintainer
Maintainer: David Peter <mail@david-peter.de>
Architecture: $architecture
Provides: $PROJECT_NAME
Conflicts: $conflictname
Homepage: $homepage
Description: A command-line benchmarking tool.
EOF
-26
View File
@@ -1,26 +0,0 @@
#!/usr/bin/env bash
set -ex
if [ "$TRAVIS_OS_NAME" != linux ]; then
exit 0
fi
sudo apt-get update
# needed to build deb packages
sudo apt-get install -y fakeroot
# needed for i686 linux gnu target
if [[ $TARGET == i686-unknown-linux-* ]]; then
sudo apt-get install -y gcc-multilib
fi
# needed for cross-compiling for arm
if [[ $TARGET == arm-unknown-linux-* ]]; then
sudo apt-get install -y \
gcc-4.8-arm-linux-gnueabihf \
binutils-arm-linux-gnueabihf \
libc6-armhf-cross \
libc6-dev-armhf-cross
fi
+3 -16
View File
@@ -10,26 +10,16 @@ import matplotlib.pyplot as plt
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("file", help="JSON file with benchmark results")
parser.add_argument("--title", help="Plot title")
parser.add_argument(
"--labels", help="Comma-separated list of entries for the plot legend"
)
parser.add_argument("--bins", help="Number of bins (default: auto)")
parser.add_argument(
"--type", help="Type of histogram (*bar*, barstacked, step, stepfilled)"
)
parser.add_argument(
"-o", "--output", help="Save image to the given filename."
)
args = parser.parse_args()
with open(args.file) as f:
results = json.load(f)["results"]
if args.labels:
labels = args.labels.split(",")
else:
labels = [b["command"] for b in results]
commands = [b["command"] for b in results]
all_times = [b["times"] for b in results]
t_min = np.min(list(map(np.min, all_times)))
@@ -39,7 +29,7 @@ bins = int(args.bins) if args.bins else "auto"
histtype = args.type if args.type else "bar"
plt.hist(
all_times, label=labels, bins=bins, histtype=histtype, range=(t_min, t_max),
all_times, label=commands, bins=bins, histtype=histtype, range=(t_min, t_max),
)
plt.legend(prop={"family": ["Source Code Pro", "Fira Mono", "Courier New"]})
@@ -47,7 +37,4 @@ plt.xlabel("Time [s]")
if args.title:
plt.title(args.title)
if args.output:
plt.savefig(args.output)
else:
plt.show()
plt.show()
+1 -7
View File
@@ -25,9 +25,6 @@ parser.add_argument(
parser.add_argument(
"--titles", help="Comma-separated list of titles for the plot legend"
)
parser.add_argument(
"-o", "--output", help="Save image to the given filename."
)
args = parser.parse_args()
if args.parameter_name is not None:
@@ -103,7 +100,4 @@ if args.log_x:
if args.titles:
plt.legend(args.titles.split(","))
if args.output:
plt.savefig(args.output)
else:
plt.show()
plt.show()
+2 -10
View File
@@ -18,10 +18,6 @@ parser.add_argument("--title", help="Plot Title")
parser.add_argument(
"--labels", help="Comma-separated list of entries for the plot legend"
)
parser.add_argument(
"-o", "--output", help="Save image to the given filename."
)
args = parser.parse_args()
with open(args.file) as f:
@@ -40,12 +36,8 @@ colors = [cmap(val / len(times)) for val in range(len(times))]
for patch, color in zip(boxplot["boxes"], colors):
patch.set_facecolor(color)
if args.title:
plt.title(args.title)
plt.title(args.title)
plt.legend(handles=boxplot["boxes"], labels=labels, loc="best", fontsize="medium")
plt.ylabel("Time [s]")
plt.ylim(0, None)
if args.output:
plt.savefig(args.output)
else:
plt.show()
plt.show()
+1 -3
View File
@@ -143,9 +143,7 @@ fn build_app() -> App<'static, 'static> {
"Perform benchmark runs for each value in the comma-separated list VALUES. \
Replaces the string '{VAR}' in each command by the current parameter value\
.\n\nExample: hyperfine -L compiler gcc,clang '{compiler} -O2 main.cpp'\n\n\
This performs benchmarks for 'gcc -O2 main.cpp' and 'clang -O2 main.cpp'.\n\n\
The option can be specified multiple times to run benchmarks for all \
possible parameter combinations.\n"
This performs benchmarks for 'gcc -O2 main.cpp' and 'clang -O2 main.cpp'.",
),
)
.arg(
+3 -9
View File
@@ -63,15 +63,9 @@ pub fn time_shell_command(
if failure_action == CmdFailureAction::RaiseError && !result.status.success() {
return Err(io::Error::new(
io::ErrorKind::Other,
format!(
"{}. \
Use the '-i'/'--ignore-failure' option if you want to ignore this. \
Alternatively, use the '--show-output' option to debug what went wrong.",
result.status.code().map_or(
"The process has been terminated by a signal".into(),
|c| format!("Command terminated with non-zero exit code: {}", c)
)
),
"Command terminated with non-zero exit code. \
Use the '-i'/'--ignore-failure' option if you want to ignore this. \
Alternatively, use the '--show-output' option to debug what went wrong.",
));
}
+3 -11
View File
@@ -2,7 +2,6 @@ use rust_decimal::Error as DecimalError;
use std::error::Error;
use std::fmt;
use std::num;
use std::num::ParseIntError;
#[derive(Debug)]
pub enum ParameterScanError {
@@ -47,14 +46,13 @@ impl fmt::Display for ParameterScanError {
impl Error for ParameterScanError {}
#[derive(Debug)]
pub enum OptionsError<'a> {
pub enum OptionsError {
RunsBelowTwo,
EmptyRunsRange,
TooManyCommandNames(usize),
NumericParsingError(&'a str, ParseIntError),
}
impl<'a> fmt::Display for OptionsError<'a> {
impl fmt::Display for OptionsError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
OptionsError::EmptyRunsRange => write!(f, "Empty runs range"),
@@ -62,14 +60,8 @@ impl<'a> fmt::Display for OptionsError<'a> {
OptionsError::TooManyCommandNames(n) => {
write!(f, "Too many --command-name options: expected {} at most", n)
}
OptionsError::NumericParsingError(cmd, ref err) => write!(
f,
"Could not read numeric argument to '--{cmd}': {err}",
cmd = cmd,
err = err
),
}
}
}
impl<'a> Error for OptionsError<'a> {}
impl Error for OptionsError {}
+4 -8
View File
@@ -8,7 +8,7 @@ use self::csv::CsvExporter;
use self::json::JsonExporter;
use self::markdown::MarkdownExporter;
use std::fs::{File, OpenOptions};
use std::fs::File;
use std::io::{Result, Write};
use crate::hyperfine::types::BenchmarkResult;
@@ -55,9 +55,7 @@ impl ExportManager {
}
/// Add an additional exporter to the ExportManager
pub fn add_exporter(&mut self, export_type: ExportType, filename: &str) -> Result<()> {
let _ = File::create(filename)?;
pub fn add_exporter(&mut self, export_type: ExportType, filename: &str) {
let exporter: Box<dyn Exporter> = match export_type {
ExportType::Asciidoc => Box::new(AsciidocExporter::default()),
ExportType::Csv => Box::new(CsvExporter::default()),
@@ -68,12 +66,10 @@ impl ExportManager {
exporter,
filename: filename.to_string(),
});
Ok(())
}
/// Write the given results to all Exporters contained within this manager
pub fn write_results(&self, results: &[BenchmarkResult], unit: Option<Unit>) -> Result<()> {
pub fn write_results(&self, results: Vec<BenchmarkResult>, unit: Option<Unit>) -> Result<()> {
for e in &self.exporters {
let file_content = e.exporter.serialize(&results, unit)?;
write_to_file(&e.filename, &file_content)?;
@@ -84,6 +80,6 @@ impl ExportManager {
/// Write the given content to a file with the specified name
fn write_to_file(filename: &str, content: &[u8]) -> Result<()> {
let mut file = OpenOptions::new().write(true).open(filename)?;
let mut file = File::create(filename)?;
file.write_all(content)
}
+1 -1
View File
@@ -13,7 +13,7 @@ pub const OUTLIER_THRESHOLD: f64 = 1.4826 * 10.0;
/// Compute modifized Z-scores for a given sample. A (unmodified) Z-score is defined by
/// `(x_i - x_mean)/x_stddev` whereas the modified Z-score is defined by `(x_i - x_median)/MAD`
/// where MAD is the median absolute deviation.
/// where MAD is the median average deviation.
///
/// References:
/// - <https://en.wikipedia.org/wiki/Median_absolute_deviation>
+24 -33
View File
@@ -49,15 +49,6 @@ fn run(
// Run the benchmarks
for (num, cmd) in commands.iter().enumerate() {
timing_results.push(run_benchmark(num, cmd, shell_spawning_time, options)?);
// Export (intermediate) results
let ans = export_manager.write_results(&timing_results, options.time_unit);
if let Err(e) = ans {
error(&format!(
"The following error occurred while exporting: {}",
e
));
}
}
// Print relative speed comparison
@@ -65,17 +56,23 @@ fn run(
write_benchmark_comparison(&timing_results);
}
// Export results
let ans = export_manager.write_results(timing_results, options.time_unit);
if let Err(e) = ans {
error(&format!(
"The following error occurred while exporting: {}",
e
));
}
Ok(())
}
fn main() {
let matches = get_arg_matches(env::args_os());
let options = build_hyperfine_options(&matches);
let export_manager = build_export_manager(&matches);
let commands = build_commands(&matches);
let export_manager = match build_export_manager(&matches) {
Ok(export_manager) => export_manager,
Err(ref e) => error(&e.to_string())
};
let res = match options {
Ok(ref opts) => run(&commands, &opts, &export_manager),
@@ -89,25 +86,20 @@ fn main() {
}
/// Build the HyperfineOptions that correspond to the given ArgMatches
fn build_hyperfine_options<'a>(
matches: &ArgMatches<'a>,
) -> Result<HyperfineOptions, OptionsError<'a>> {
fn build_hyperfine_options(matches: &ArgMatches<'_>) -> Result<HyperfineOptions, OptionsError> {
let mut options = HyperfineOptions::default();
let param_to_u64 = |param| {
matches
.value_of(param)
.map(|n| {
u64::from_str_radix(n, 10).map_err(|e| OptionsError::NumericParsingError(param, e))
})
.transpose()
.and_then(|n| u64::from_str_radix(n, 10).ok())
};
options.warmup_count = param_to_u64("warmup")?.unwrap_or(options.warmup_count);
options.warmup_count = param_to_u64("warmup").unwrap_or(options.warmup_count);
let mut min_runs = param_to_u64("min-runs")?;
let mut max_runs = param_to_u64("max-runs")?;
let mut min_runs = param_to_u64("min-runs");
let mut max_runs = param_to_u64("max-runs");
if let Some(runs) = param_to_u64("runs")? {
if let Some(runs) = param_to_u64("runs") {
min_runs = Some(runs);
max_runs = Some(runs);
}
@@ -205,21 +197,20 @@ fn build_hyperfine_options<'a>(
/// Build the ExportManager that will export the results specified
/// in the given ArgMatches
fn build_export_manager(matches: &ArgMatches<'_>) -> io::Result<ExportManager> {
fn build_export_manager(matches: &ArgMatches<'_>) -> ExportManager {
let mut export_manager = ExportManager::new();
{
let mut add_exporter = |flag, exporttype| -> io::Result<()> {
let mut add_exporter = |flag, exporttype| {
if let Some(filename) = matches.value_of(flag) {
export_manager.add_exporter(exporttype, filename)?;
export_manager.add_exporter(exporttype, filename);
}
Ok(())
};
add_exporter("export-asciidoc", ExportType::Asciidoc)?;
add_exporter("export-json", ExportType::Json)?;
add_exporter("export-csv", ExportType::Csv)?;
add_exporter("export-markdown", ExportType::Markdown)?;
add_exporter("export-asciidoc", ExportType::Asciidoc);
add_exporter("export-json", ExportType::Json);
add_exporter("export-csv", ExportType::Csv);
add_exporter("export-markdown", ExportType::Markdown);
}
Ok(export_manager)
export_manager
}
/// Build the commands to benchmark