mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-20 03:11:28 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2859150219 | ||
|
|
2e24ff012a | ||
|
|
d5c21ec272 | ||
|
|
2ddc21c7d4 | ||
|
|
cda5816dd3 | ||
|
|
e4e937715e | ||
|
|
2784b7fc1b | ||
|
|
1fc78cd59b | ||
|
|
a08581e33a | ||
|
|
bda623eb75 | ||
|
|
d7dc7804b4 | ||
|
|
241b89f12b | ||
|
|
ef2bef588c | ||
|
|
35a513917d | ||
|
|
0a77b43d17 | ||
|
|
793b561d4c | ||
|
|
ae47586998 | ||
|
|
93386dc808 | ||
|
|
bd5d5fd4fa | ||
|
|
d42994bf64 | ||
|
|
f44f24c8d9 | ||
|
|
a656fbe508 | ||
|
|
d5e02ff768 | ||
|
|
b6ca2d6ac2 | ||
|
|
f29bbb58eb | ||
|
|
a4df90e44c | ||
|
|
b0bab45e51 | ||
|
|
1fe3c66430 | ||
|
|
933d167201 | ||
|
|
5d06e3979c |
No files matched your search
+95
@@ -0,0 +1,95 @@
|
||||
language: rust
|
||||
cache: cargo
|
||||
matrix:
|
||||
include:
|
||||
# Stable channel.
|
||||
- os: linux
|
||||
rust: stable
|
||||
env: TARGET=x86_64-unknown-linux-gnu
|
||||
- os: linux
|
||||
rust: stable
|
||||
env: TARGET=x86_64-unknown-linux-musl
|
||||
- os: linux
|
||||
rust: stable
|
||||
env: TARGET=i686-unknown-linux-gnu
|
||||
- os: linux
|
||||
rust: stable
|
||||
env: TARGET=i686-unknown-linux-musl
|
||||
- os: osx
|
||||
rust: stable
|
||||
env: TARGET=x86_64-apple-darwin
|
||||
|
||||
# Minimum Rust supported channel.
|
||||
- os: linux
|
||||
rust: 1.20.0
|
||||
env: TARGET=x86_64-unknown-linux-gnu
|
||||
- os: linux
|
||||
rust: 1.20.0
|
||||
env: TARGET=x86_64-unknown-linux-musl
|
||||
- os: linux
|
||||
rust: 1.20.0
|
||||
env: TARGET=i686-unknown-linux-gnu
|
||||
- os: linux
|
||||
rust: 1.20.0
|
||||
env: TARGET=i686-unknown-linux-musl
|
||||
- os: osx
|
||||
rust: 1.20.0
|
||||
env: TARGET=x86_64-apple-darwin
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
# needed for i686-unknown-linux-gnu target
|
||||
- gcc-multilib
|
||||
# needed to build deb packages
|
||||
- fakeroot
|
||||
|
||||
env:
|
||||
global:
|
||||
# Default target on travis-ci.
|
||||
# Used as conditional check in the install stage
|
||||
- HOST=x86_64-unknown-linux-gnu
|
||||
# Used on the deployment script
|
||||
- PROJECT_NAME=hyperfine
|
||||
|
||||
install:
|
||||
# prevent target re-add error from rustup
|
||||
- if [[ $TRAVIS_OS_NAME = linux && $HOST != $TARGET ]]; then rustup target add $TARGET; fi
|
||||
|
||||
script:
|
||||
# Incorporate TARGET env var to the build and test process
|
||||
- cargo build --target $TARGET --verbose
|
||||
- cargo test --target $TARGET --verbose
|
||||
|
||||
before_deploy:
|
||||
- bash ci/before_deploy.bash
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
# 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
|
||||
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
|
||||
# NOTE explanation on each env variable
|
||||
# - PROJECT_NAME: name of the project, set on the `env.global` above
|
||||
# - TRAVIS_TAG: tag name that the build is being deployed for, usually the version number
|
||||
# - TARGET: target triple of the build
|
||||
file:
|
||||
- $PROJECT_NAME-$TRAVIS_TAG-$TARGET.*
|
||||
- $PROJECT_NAME*.deb
|
||||
# don't delete artifacts from previous stage
|
||||
skip_cleanup: true
|
||||
on:
|
||||
# deploy only if we push a tag
|
||||
tags: true
|
||||
# deploy only on stable channel that has TARGET env variable sets
|
||||
condition: $TRAVIS_RUST_VERSION = stable && $TARGET != ""
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
Generated
+55
-38
@@ -11,6 +11,11 @@ name = "ansi_term"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "approx"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.6"
|
||||
@@ -18,7 +23,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -28,7 +33,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "2.29.1"
|
||||
version = "2.29.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -42,29 +47,36 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "clicolors-control"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "colored"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "console"
|
||||
version = "0.5.0"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"clicolors-control 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clicolors-control 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"termios 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -83,20 +95,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "hyperfine"
|
||||
version = "0.2.0"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.29.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"indicatif 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"approx 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.29.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"indicatif 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"statistical 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indicatif"
|
||||
version = "0.8.0"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"console 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"console 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@@ -143,8 +158,8 @@ dependencies = [
|
||||
"num-complex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-rational 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-rational 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -153,7 +168,7 @@ version = "0.1.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@@ -163,7 +178,7 @@ name = "num-complex"
|
||||
version = "0.1.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
@@ -172,7 +187,7 @@ name = "num-integer"
|
||||
version = "0.1.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -181,23 +196,23 @@ version = "0.1.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.1.40"
|
||||
version = "0.1.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"num-bigint 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.1.41"
|
||||
version = "0.1.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
@@ -225,7 +240,7 @@ dependencies = [
|
||||
"libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.3.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -372,11 +387,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -386,25 +401,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.3.2"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.3.2"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4"
|
||||
"checksum ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b3568b48b7cefa6b8ce125f9bb4989e52fbcc29ebea88df04cc7c5f12f70455"
|
||||
"checksum approx 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08abcc3b4e9339e33a3d0a5ed15d84a687350c05689d825e0f6655eef9e76a94"
|
||||
"checksum atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8352656fd42c30a0c3c89d26dea01e3b77c0ab2af18230835c15e2e13cd51859"
|
||||
"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf"
|
||||
"checksum clap 2.29.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8f4a2b3bb7ef3c672d7c13d15613211d5a6976b6892c598b0fcb5d40765f19c2"
|
||||
"checksum clicolors-control 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "61bd6bff2f99f947c2dbdc73cd0ebd55d8263b921fd4f68a44598555be49f32b"
|
||||
"checksum console 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21d6020031c1b7b2b1aa3f9c35568735c46270c6b0e9b338aae6e4a062301711"
|
||||
"checksum clap 2.29.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4151c5790817c7d21bbdc6c3530811f798172915f93258244948b93ba19604a6"
|
||||
"checksum clicolors-control 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1f84dec9bc083ce2503908cd305af98bd363da6f54bf8d4bf0ac14ee749ad5d1"
|
||||
"checksum colored 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b0aa3473e85a3161b59845d6096b289bb577874cafeaf75ea1b1beaa6572c7fc"
|
||||
"checksum console 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7649ca90478264b9686aac8d269fcb014f14c2bed7c79a7e51b9f6afd4d783eb"
|
||||
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
|
||||
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
|
||||
"checksum indicatif 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15aea47abd6d77e1a2d9f17abf42558a647d8c4e0400bff4baa0ced335b78d37"
|
||||
"checksum indicatif 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a29b2fa6f00010c268bface64c18bb0310aaa70d46a195d5382d288c477fb016"
|
||||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
|
||||
"checksum lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c8f31047daa365f19be14b47c29df4f7c3b581832407daabe6ae77397619237d"
|
||||
@@ -415,8 +432,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum num-complex 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "58de7b4bf7cf5dbecb635a5797d489864eadd03b107930cbccf9e0fd7428b47c"
|
||||
"checksum num-integer 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "d1452e8b06e448a07f0e6ebb0bb1d92b8890eea63288c0b627331d53514d0fba"
|
||||
"checksum num-iter 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)" = "7485fcc84f85b4ecd0ea527b14189281cf27d60e583ae65ebc9c088b13dffe01"
|
||||
"checksum num-rational 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "0c7cb72a95250d8a370105c828f388932373e0e94414919891a0f945222310fe"
|
||||
"checksum num-traits 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "cacfcab5eb48250ee7d0c7896b51a2c5eec99c1feea5f32025635f5ae4b00070"
|
||||
"checksum num-rational 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "0b950f75e042fdd710460084d19c8efdcd72d65183ead8ecd04b90483f5a55d2"
|
||||
"checksum num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9936036cc70fe4a8b2d338ab665900323290efb03983c86cbe235ae800ad8017"
|
||||
"checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37"
|
||||
"checksum parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3e7f7c9857874e54afeb950eebeae662b1e51a2493666d2ea4c0a5d91dcf0412"
|
||||
"checksum parking_lot_core 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "9f35048d735bb93dd115a0030498785971aab3234d311fbe273d020084d26bd8"
|
||||
@@ -440,7 +457,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
|
||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
|
||||
"checksum winapi 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b09fb3b6f248ea4cd42c9a65113a847d612e17505d6ebd1f7357ad68a8bf8693"
|
||||
"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3"
|
||||
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ec6667f60c23eca65c561e63a13d81b44234c2e38a6b6c959025ee907ec614cc"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "98f12c52b2630cd05d2c3ffd8e008f7f48252c042b4871c72aed9dc733b96668"
|
||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
+8
-3
@@ -7,14 +7,19 @@ license = "MIT/Apache-2.0"
|
||||
name = "hyperfine"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/sharkdp/hyperfine"
|
||||
version = "0.2.0"
|
||||
version = "0.4.0"
|
||||
|
||||
[dependencies]
|
||||
ansi_term = "0.10"
|
||||
indicatif = "0.8"
|
||||
colored = "1.6"
|
||||
indicatif = "0.9"
|
||||
statistical = "0.1"
|
||||
libc = "0.2"
|
||||
atty = "0.2.2"
|
||||
|
||||
[dependencies.clap]
|
||||
version = "2"
|
||||
default-features = false
|
||||
features = ["suggestions", "color", "wrap_help"]
|
||||
|
||||
[dev-dependencies]
|
||||
approx = "0.1.1"
|
||||
@@ -1,30 +1,87 @@
|
||||
# hyperfine
|
||||
[](https://travis-ci.org/sharkdp/hyperfine)
|
||||
[](https://crates.io/crates/hyperfine)
|
||||
|
||||
A command-line benchmarking tool (inspired by [bench](https://github.com/Gabriel439/bench)).
|
||||
A command-line benchmarking tool (*inspired by [bench](https://github.com/Gabriel439/bench)*).
|
||||
|
||||
Usage
|
||||
``` bash
|
||||
> hyperfine 'sleep 0.3' 'sleep 1.7'
|
||||
```
|
||||
|
||||
## Demo
|
||||
**Demo**: Benchmarking [`fd`](https://github.com/sharkdp/fd) and
|
||||
[`find`](https://www.gnu.org/software/findutils/):
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
|
||||
* Statistical analysis across multiple runs
|
||||
* Support for arbitrary shell commands
|
||||
* Visual indication of the benchmark progress
|
||||
* Warmup runs that are executed before the actual benchmark
|
||||
* Statistical analysis across multiple runs.
|
||||
* Support for arbitrary shell commands.
|
||||
* Constant feedback about the benchmark progress and current estimates.
|
||||
* Warmup runs can be executed before the actual benchmark.
|
||||
* Cache-clearing commands can be set up before each timing run.
|
||||
* Statisical outlier detection.
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic benchmark
|
||||
|
||||
To run a benchmark, you can simply call `hyperfine <command>...`. The argument(s) can be any
|
||||
shell command. For example:
|
||||
``` bash
|
||||
hyperfine 'sleep 0.3'
|
||||
```
|
||||
|
||||
Hyperfine will automatically determine the number of runs to perform for each command. By default,
|
||||
it will perform *at least* 10 benchmarking runs. To change this, you can use the `-m`/`--min-runs`
|
||||
option:
|
||||
``` bash
|
||||
hyperfine --min-runs 5 'sleep 0.2' 'sleep 3.2'
|
||||
```
|
||||
|
||||
### I/O-heavy programs
|
||||
|
||||
If the program execution time is limited by disk I/O, the benchmarking results can be heavily
|
||||
influence by disk caches and whether they are cold or warm.
|
||||
|
||||
If you want to run the benchmark on a warm cache, you can use the `-w`/`--warmup` option to perform
|
||||
a certain number of program executions before the actual benchmark:
|
||||
``` bash
|
||||
hyperfine --warmup 3 'grep -R TODO *'
|
||||
```
|
||||
|
||||
Conversely, if you want to run the benchmark for a cold cache, you can use the `-p`/`--prepare`
|
||||
option to run a special command before *each* timing run. For example, to clear harddisk caches
|
||||
on Linux, you can run
|
||||
``` bash
|
||||
sync; echo 3 | sudo tee /proc/sys/vm/drop_caches
|
||||
```
|
||||
To use this specific command with Hyperfine, call `sudo -v` to temporarily gain sudo permissions
|
||||
and then call:
|
||||
``` bash
|
||||
hyperfine --prepare 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches' 'grep -R TODO *'
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
Hyperfine can be install via [cargo](https://doc.rust-lang.org/cargo/):
|
||||
Hyperfine can be installed via [cargo](https://doc.rust-lang.org/cargo/):
|
||||
```
|
||||
cargo install hyperfine
|
||||
```
|
||||
|
||||
### Arch Linux
|
||||
|
||||
On Arch Linux, hyperfine can be installed [from the AUR](https://aur.archlinux.org/packages/hyperfine):
|
||||
```
|
||||
yaourt -S hyperfine
|
||||
```
|
||||
|
||||
### Ubuntu
|
||||
|
||||
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/v0.4.0/hyperfine_0.4.0_amd64.deb
|
||||
sudo dpkg -i hyperfine_0.4.0_amd64.deb
|
||||
```
|
||||
|
||||
|
||||
## Origin of the name
|
||||
|
||||
The name *hyperfine* was chosen in reference to the hyperfine levels of caesium 133 which play a crucial role in the
|
||||
|
||||
Executable
+103
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env bash
|
||||
# Building and packaging for release
|
||||
|
||||
set -ex
|
||||
|
||||
build() {
|
||||
cargo build --target "$TARGET" --release --verbose
|
||||
}
|
||||
|
||||
pack() {
|
||||
local tempdir
|
||||
local out_dir
|
||||
local package_name
|
||||
|
||||
tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
|
||||
out_dir=$(pwd)
|
||||
package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET"
|
||||
|
||||
# create a "staging" directory
|
||||
mkdir "$tempdir/$package_name"
|
||||
|
||||
# copying the main binary
|
||||
cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/"
|
||||
strip "$tempdir/$package_name/$PROJECT_NAME"
|
||||
|
||||
# readme and license
|
||||
cp README.md "$tempdir/$package_name"
|
||||
cp LICENSE-MIT "$tempdir/$package_name"
|
||||
cp LICENSE-APACHE "$tempdir/$package_name"
|
||||
|
||||
# archiving
|
||||
pushd "$tempdir"
|
||||
tar czf "$out_dir/$package_name.tar.gz" "$package_name"/*
|
||||
popd
|
||||
rm -r "$tempdir"
|
||||
}
|
||||
|
||||
make_deb() {
|
||||
local tempdir
|
||||
local architecture
|
||||
local version
|
||||
local dpkgname
|
||||
local conflictname
|
||||
|
||||
case $TARGET in
|
||||
x86_64*)
|
||||
architecture=amd64
|
||||
;;
|
||||
i686*)
|
||||
architecture=i386
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: unknown target" >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
version=${TRAVIS_TAG#v}
|
||||
if [[ $TARGET = *musl* ]]; then
|
||||
dpkgname=$PROJECT_NAME-musl
|
||||
conflictname=$PROJECT_NAME
|
||||
else
|
||||
dpkgname=$PROJECT_NAME
|
||||
conflictname=$PROJECT_NAME-musl
|
||||
fi
|
||||
|
||||
tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp)
|
||||
|
||||
# copy the main binary
|
||||
install -Dm755 "target/$TARGET/release/$PROJECT_NAME" "$tempdir/usr/bin/$PROJECT_NAME"
|
||||
strip "$tempdir/usr/bin/$PROJECT_NAME"
|
||||
|
||||
# readme and license
|
||||
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"
|
||||
|
||||
# Control file
|
||||
mkdir "$tempdir/DEBIAN"
|
||||
cat > "$tempdir/DEBIAN/control" <<EOF
|
||||
Package: $dpkgname
|
||||
Version: $version
|
||||
Section: utils
|
||||
Priority: optional
|
||||
Maintainer: David Peter <mail@david-peter.de>
|
||||
Architecture: $architecture
|
||||
Provides: $PROJECT_NAME
|
||||
Conflicts: $conflictname
|
||||
Description: A command-line benchmarking tool.
|
||||
EOF
|
||||
|
||||
fakeroot dpkg-deb --build "$tempdir" "${dpkgname}_${version}_${architecture}.deb"
|
||||
}
|
||||
|
||||
|
||||
main() {
|
||||
build
|
||||
pack
|
||||
if [[ $TARGET = *linux* ]]; then
|
||||
make_deb
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
||||
+162
-83
@@ -2,38 +2,46 @@ use std::io;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::time::Instant;
|
||||
|
||||
use ansi_term::Colour::{Cyan, Green, White, Yellow, Purple};
|
||||
use colored::*;
|
||||
use statistical::{mean, standard_deviation};
|
||||
|
||||
use hyperfine::internal::{get_progress_bar, max, min, HyperfineOptions, Second, Warnings,
|
||||
MIN_EXECUTION_TIME};
|
||||
use hyperfine::format::{format_duration, format_duration_unit, Unit};
|
||||
use hyperfine::internal::{get_progress_bar, max, min, CmdFailureAction, HyperfineOptions,
|
||||
OutputStyleOption, Second, MIN_EXECUTION_TIME};
|
||||
use hyperfine::warnings::Warnings;
|
||||
use hyperfine::format::{format_duration, format_duration_unit};
|
||||
use hyperfine::cputime::{cpu_time_interval, get_cpu_times};
|
||||
use hyperfine::outlier_detection::{modified_zscores, OUTLIER_THRESHOLD};
|
||||
|
||||
/// Results from timing a single shell command
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct TimingResult {
|
||||
/// Execution time in seconds
|
||||
pub execution_time: Second,
|
||||
/// Wall clock time
|
||||
pub time_real: Second,
|
||||
|
||||
/// True if the command finished with exit code zero
|
||||
pub success: bool,
|
||||
/// Time spent in user mode
|
||||
pub time_user: Second,
|
||||
|
||||
/// Time spent in kernel mode
|
||||
pub time_system: Second,
|
||||
}
|
||||
|
||||
impl TimingResult {
|
||||
fn new(execution_time: Second, success: bool) -> TimingResult {
|
||||
TimingResult {
|
||||
execution_time,
|
||||
success,
|
||||
}
|
||||
/// Correct for shell spawning time
|
||||
fn subtract_shell_spawning_time(time: Second, shell_spawning_time: Second) -> Second {
|
||||
if time < shell_spawning_time {
|
||||
0.0
|
||||
} else {
|
||||
time - shell_spawning_time
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the given shell command and measure the execution time
|
||||
pub fn time_shell_command(
|
||||
shell_cmd: &str,
|
||||
ignore_failure: bool,
|
||||
shell_spawning_time: Option<Second>,
|
||||
) -> io::Result<TimingResult> {
|
||||
failure_action: CmdFailureAction,
|
||||
shell_spawning_time: Option<TimingResult>,
|
||||
) -> io::Result<(TimingResult, bool)> {
|
||||
let start = Instant::now();
|
||||
let start_cpu = get_cpu_times();
|
||||
|
||||
let status = Command::new("sh")
|
||||
.arg("-c")
|
||||
@@ -43,7 +51,10 @@ pub fn time_shell_command(
|
||||
.stderr(Stdio::null())
|
||||
.status()?;
|
||||
|
||||
if !ignore_failure && !status.success() {
|
||||
let end_cpu = get_cpu_times();
|
||||
let duration = start.elapsed();
|
||||
|
||||
if failure_action == CmdFailureAction::RaiseError && !status.success() {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"Command terminated with non-zero exit code. \
|
||||
@@ -51,36 +62,43 @@ pub fn time_shell_command(
|
||||
));
|
||||
}
|
||||
|
||||
let duration = start.elapsed();
|
||||
// Real time
|
||||
let mut time_real = duration.as_secs() as f64 + (duration.subsec_nanos() as f64) * 1e-9;
|
||||
|
||||
let execution_time = duration.as_secs() as f64 + duration.subsec_nanos() as f64 * 1e-9;
|
||||
// User and system time
|
||||
let cpu_interval = cpu_time_interval(&start_cpu, &end_cpu);
|
||||
let mut time_user = cpu_interval.user;
|
||||
let mut time_system = cpu_interval.system;
|
||||
|
||||
// Correct for shell spawning time
|
||||
let execution_time_corrected = if let Some(spawning_time) = shell_spawning_time {
|
||||
if execution_time < spawning_time {
|
||||
0.0
|
||||
} else {
|
||||
execution_time - spawning_time
|
||||
}
|
||||
} else {
|
||||
execution_time
|
||||
};
|
||||
if let Some(spawning_time) = shell_spawning_time {
|
||||
time_real = subtract_shell_spawning_time(time_real, spawning_time.time_real);
|
||||
time_user = subtract_shell_spawning_time(cpu_interval.user, spawning_time.time_user);
|
||||
time_system = subtract_shell_spawning_time(cpu_interval.system, spawning_time.time_system);
|
||||
}
|
||||
|
||||
Ok(TimingResult::new(
|
||||
execution_time_corrected,
|
||||
Ok((
|
||||
TimingResult {
|
||||
time_real,
|
||||
time_user,
|
||||
time_system,
|
||||
},
|
||||
status.success(),
|
||||
))
|
||||
}
|
||||
|
||||
/// Measure the average shell spawning time
|
||||
pub fn mean_shell_spawning_time() -> io::Result<Second> {
|
||||
pub fn mean_shell_spawning_time(style: &OutputStyleOption) -> io::Result<TimingResult> {
|
||||
const COUNT: u64 = 200;
|
||||
let bar = get_progress_bar(COUNT, "Measuring shell spawning time");
|
||||
let progress_bar = get_progress_bar(COUNT, "Measuring shell spawning time", style);
|
||||
|
||||
let mut times_real: Vec<Second> = vec![];
|
||||
let mut times_user: Vec<Second> = vec![];
|
||||
let mut times_system: Vec<Second> = vec![];
|
||||
|
||||
let mut times: Vec<Second> = vec![];
|
||||
for _ in 0..COUNT {
|
||||
// Just run the shell without any command
|
||||
let res = time_shell_command("", false, None);
|
||||
let res = time_shell_command("", CmdFailureAction::RaiseError, None);
|
||||
|
||||
match res {
|
||||
Err(_) => {
|
||||
@@ -90,55 +108,90 @@ pub fn mean_shell_spawning_time() -> io::Result<Second> {
|
||||
Make sure you can run 'sh -c \"\"'.",
|
||||
))
|
||||
}
|
||||
Ok(r) => {
|
||||
times.push(r.execution_time);
|
||||
Ok((r, _)) => {
|
||||
times_real.push(r.time_real);
|
||||
times_user.push(r.time_user);
|
||||
times_system.push(r.time_system);
|
||||
}
|
||||
}
|
||||
bar.inc(1);
|
||||
progress_bar.inc(1);
|
||||
}
|
||||
bar.finish_and_clear();
|
||||
progress_bar.finish_and_clear();
|
||||
|
||||
Ok(mean(×))
|
||||
Ok(TimingResult {
|
||||
time_real: mean(×_real),
|
||||
time_user: mean(×_user),
|
||||
time_system: mean(×_system),
|
||||
})
|
||||
}
|
||||
|
||||
/// Run the command specified by `--prepare`.
|
||||
fn run_preparation_command(command: &Option<String>) -> io::Result<()> {
|
||||
if let &Some(ref preparation_command) = command {
|
||||
let res = time_shell_command(preparation_command, CmdFailureAction::RaiseError, None);
|
||||
if res.is_err() {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"The preparation command terminated with a non-zero exit code. \
|
||||
Append ' || true' to the command if you are sure that this can be ignored.",
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Run the benchmark for a single shell command
|
||||
pub fn run_benchmark(
|
||||
num: usize,
|
||||
cmd: &str,
|
||||
shell_spawning_time: Second,
|
||||
shell_spawning_time: TimingResult,
|
||||
options: &HyperfineOptions,
|
||||
) -> io::Result<()> {
|
||||
println!(
|
||||
"{}{}: {}",
|
||||
White.bold().paint("Benchmark #"),
|
||||
White.bold().paint((num + 1).to_string()),
|
||||
"Benchmark #".bold(),
|
||||
(num + 1).to_string().bold(),
|
||||
cmd
|
||||
);
|
||||
println!();
|
||||
|
||||
let mut execution_times: Vec<Second> = vec![];
|
||||
let mut times_real: Vec<Second> = vec![];
|
||||
let mut times_user: Vec<Second> = vec![];
|
||||
let mut times_system: Vec<Second> = vec![];
|
||||
let mut all_succeeded = true;
|
||||
|
||||
// Warmup phase
|
||||
if options.warmup_count > 0 {
|
||||
let bar = get_progress_bar(options.warmup_count, "Performing warmup runs");
|
||||
let progress_bar = get_progress_bar(
|
||||
options.warmup_count,
|
||||
"Performing warmup runs",
|
||||
&options.output_style,
|
||||
);
|
||||
|
||||
for _ in 0..options.warmup_count {
|
||||
let _ = time_shell_command(cmd, options.ignore_failure, None)?;
|
||||
bar.inc(1);
|
||||
let _ = time_shell_command(cmd, options.failure_action, None)?;
|
||||
progress_bar.inc(1);
|
||||
}
|
||||
bar.finish_and_clear();
|
||||
progress_bar.finish_and_clear();
|
||||
}
|
||||
|
||||
// Set up progress bar (and spinner for initial measurement)
|
||||
let bar = get_progress_bar(options.min_runs, "Initial time measurement");
|
||||
let progress_bar = get_progress_bar(
|
||||
options.min_runs,
|
||||
"Initial time measurement",
|
||||
&options.output_style,
|
||||
);
|
||||
|
||||
// Run init / cleanup command
|
||||
run_preparation_command(&options.preparation_command)?;
|
||||
|
||||
// Initial timing run
|
||||
let res = time_shell_command(cmd, options.ignore_failure, Some(shell_spawning_time))?;
|
||||
let (res, success) =
|
||||
time_shell_command(cmd, options.failure_action, Some(shell_spawning_time))?;
|
||||
|
||||
// Determine number of benchmark runs
|
||||
let runs_in_min_time =
|
||||
(options.min_time_sec / (res.execution_time + shell_spawning_time)) as u64;
|
||||
(options.min_time_sec / (res.time_real + shell_spawning_time.time_real)) as u64;
|
||||
|
||||
let count = if runs_in_min_time >= options.min_runs {
|
||||
runs_in_min_time
|
||||
@@ -149,63 +202,80 @@ pub fn run_benchmark(
|
||||
let count_remaining = count - 1;
|
||||
|
||||
// Save the first result
|
||||
execution_times.push(res.execution_time);
|
||||
all_succeeded = all_succeeded && res.success;
|
||||
times_real.push(res.time_real);
|
||||
times_user.push(res.time_user);
|
||||
times_system.push(res.time_system);
|
||||
|
||||
all_succeeded = all_succeeded && success;
|
||||
|
||||
// Re-configure the progress bar
|
||||
bar.set_length(count_remaining);
|
||||
progress_bar.set_length(count_remaining);
|
||||
|
||||
// Gather statistics
|
||||
for _ in 0..count_remaining {
|
||||
run_preparation_command(&options.preparation_command)?;
|
||||
|
||||
let msg = {
|
||||
let mean = format_duration(mean(&execution_times), Unit::Auto);
|
||||
format!("Current estimate: {}", Green.paint(mean))
|
||||
let mean = format_duration(mean(×_real), None);
|
||||
format!("Current estimate: {}", mean.to_string().green())
|
||||
};
|
||||
bar.set_message(&msg);
|
||||
progress_bar.set_message(&msg);
|
||||
|
||||
let res = time_shell_command(cmd, options.ignore_failure, Some(shell_spawning_time))?;
|
||||
let (res, success) =
|
||||
time_shell_command(cmd, options.failure_action, Some(shell_spawning_time))?;
|
||||
|
||||
execution_times.push(res.execution_time);
|
||||
all_succeeded = all_succeeded && res.success;
|
||||
times_real.push(res.time_real);
|
||||
times_user.push(res.time_user);
|
||||
times_system.push(res.time_system);
|
||||
|
||||
bar.inc(1);
|
||||
all_succeeded = all_succeeded && success;
|
||||
|
||||
progress_bar.inc(1);
|
||||
}
|
||||
bar.finish_and_clear();
|
||||
progress_bar.finish_and_clear();
|
||||
|
||||
// Compute statistical quantities
|
||||
let t_mean = mean(&execution_times);
|
||||
let t_stddev = standard_deviation(&execution_times, Some(t_mean));
|
||||
let t_min = min(&execution_times);
|
||||
let t_max = max(&execution_times);
|
||||
let t_mean = mean(×_real);
|
||||
let t_stddev = standard_deviation(×_real, Some(t_mean));
|
||||
let t_min = min(×_real);
|
||||
let t_max = max(×_real);
|
||||
|
||||
let user_mean = mean(×_user);
|
||||
let system_mean = mean(×_system);
|
||||
|
||||
// Formatting and console output
|
||||
let (mean_str, unit_mean) = format_duration_unit(t_mean, Unit::Auto);
|
||||
let stddev_str = format_duration(t_stddev, unit_mean);
|
||||
let min_str = format_duration(t_min, unit_mean);
|
||||
let max_str = format_duration(t_max, unit_mean);
|
||||
let (mean_str, unit_mean) = format_duration_unit(t_mean, None);
|
||||
let stddev_str = format_duration(t_stddev, Some(unit_mean));
|
||||
let min_str = format_duration(t_min, Some(unit_mean));
|
||||
let max_str = format_duration(t_max, Some(unit_mean));
|
||||
|
||||
let (user_str, user_unit) = format_duration_unit(user_mean, None);
|
||||
let system_str = format_duration(system_mean, Some(user_unit));
|
||||
|
||||
println!(
|
||||
" Time ({} ± {}): {} ± {}",
|
||||
Green.bold().paint("mean"),
|
||||
Green.paint("σ"),
|
||||
Green.bold().paint(mean_str),
|
||||
Green.paint(stddev_str)
|
||||
" Time ({} ± {}): {:>8} ± {:>8} [User: {}, System: {}]",
|
||||
"mean".green().bold(),
|
||||
"σ".green(),
|
||||
mean_str.green().bold(),
|
||||
stddev_str.green(),
|
||||
user_str.blue(),
|
||||
system_str.blue()
|
||||
);
|
||||
println!(" ");
|
||||
|
||||
println!(
|
||||
" Range ({} … {}): {} … {}",
|
||||
Cyan.paint("min"),
|
||||
Purple.paint("max"),
|
||||
Cyan.paint(min_str),
|
||||
Purple.paint(max_str)
|
||||
" Range ({} … {}): {:>8} … {:>8}",
|
||||
"min".cyan(),
|
||||
"max".purple(),
|
||||
min_str.cyan(),
|
||||
max_str.purple()
|
||||
);
|
||||
|
||||
// Warnings
|
||||
let mut warnings = vec![];
|
||||
|
||||
// Check execution time
|
||||
if execution_times.iter().any(|&t| t < MIN_EXECUTION_TIME) {
|
||||
if times_real.iter().any(|&t| t < MIN_EXECUTION_TIME) {
|
||||
warnings.push(Warnings::FastExecutionTime);
|
||||
}
|
||||
|
||||
@@ -214,10 +284,19 @@ pub fn run_benchmark(
|
||||
warnings.push(Warnings::NonZeroExitCode);
|
||||
}
|
||||
|
||||
if warnings.len() > 0 {
|
||||
// Run outlier detection
|
||||
let scores = modified_zscores(×_real);
|
||||
if scores[0] > OUTLIER_THRESHOLD {
|
||||
warnings.push(Warnings::SlowInitialRun(times_real[0]));
|
||||
} else if scores.iter().any(|&s| s > OUTLIER_THRESHOLD) {
|
||||
warnings.push(Warnings::OutliersDetected);
|
||||
}
|
||||
|
||||
if !warnings.is_empty() {
|
||||
eprintln!(" ");
|
||||
|
||||
for warning in &warnings {
|
||||
eprintln!(" {}: {}", Yellow.paint("Warning"), warning);
|
||||
eprintln!(" {}: {}", "Warning".yellow(), warning);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
use libc::{getrusage, rusage, RUSAGE_CHILDREN};
|
||||
use std::mem;
|
||||
|
||||
use hyperfine::internal::Second;
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct CPUTimes {
|
||||
/// Total amount of time spent executing in user mode
|
||||
user_usec: i64,
|
||||
|
||||
/// Total amount of time spent executing in kernel mode
|
||||
system_usec: i64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct CPUInterval {
|
||||
/// Total amount of time spent executing in user mode
|
||||
pub user: Second,
|
||||
|
||||
/// Total amount of time spent executing in kernel mode
|
||||
pub system: Second,
|
||||
}
|
||||
|
||||
/// Read CPU execution times ('user' and 'system')
|
||||
pub fn get_cpu_times() -> CPUTimes {
|
||||
let result: rusage = unsafe {
|
||||
let mut buf = mem::zeroed();
|
||||
let success = getrusage(RUSAGE_CHILDREN, &mut buf);
|
||||
assert_eq!(0, success);
|
||||
buf
|
||||
};
|
||||
|
||||
const MICROSEC_PER_SEC: i64 = 1000 * 1000;
|
||||
|
||||
CPUTimes {
|
||||
user_usec: i64::from(result.ru_utime.tv_sec) * MICROSEC_PER_SEC
|
||||
+ i64::from(result.ru_utime.tv_usec),
|
||||
system_usec: i64::from(result.ru_stime.tv_sec) * MICROSEC_PER_SEC
|
||||
+ i64::from(result.ru_stime.tv_usec),
|
||||
}
|
||||
}
|
||||
|
||||
/// Compute the time intervals in between two `CPUTimes` snapshots
|
||||
pub fn cpu_time_interval(start: &CPUTimes, end: &CPUTimes) -> CPUInterval {
|
||||
CPUInterval {
|
||||
user: ((end.user_usec - start.user_usec) as f64) * 1e-6,
|
||||
system: ((end.system_usec - start.system_usec) as f64) * 1e-6,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cpu_time_interval() {
|
||||
let t_a = CPUTimes {
|
||||
user_usec: 12345,
|
||||
system_usec: 54321,
|
||||
};
|
||||
|
||||
let t_b = CPUTimes {
|
||||
user_usec: 20000,
|
||||
system_usec: 70000,
|
||||
};
|
||||
|
||||
let t_zero = cpu_time_interval(&t_a, &t_a);
|
||||
assert_eq!(0.0, t_zero.user);
|
||||
assert_eq!(0.0, t_zero.system);
|
||||
|
||||
let t_ab = cpu_time_interval(&t_a, &t_b);
|
||||
assert_relative_eq!(0.007655, t_ab.user);
|
||||
assert_relative_eq!(0.015679, t_ab.system);
|
||||
|
||||
let t_ba = cpu_time_interval(&t_b, &t_a);
|
||||
assert_relative_eq!(-0.007655, t_ba.user);
|
||||
assert_relative_eq!(-0.015679, t_ba.system);
|
||||
}
|
||||
+50
-7
@@ -1,22 +1,65 @@
|
||||
use hyperfine::internal::Second;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Unit {
|
||||
Auto,
|
||||
Second,
|
||||
MilliSecond,
|
||||
}
|
||||
|
||||
pub fn format_duration(duration: Second, unit: Unit) -> String {
|
||||
/// Format the given duration as a string. The output-unit can be enforced by setting `unit` to
|
||||
/// `Some(target_unit)`. If `unit` is `None`, it will be determined automatically.
|
||||
pub fn format_duration(duration: Second, unit: Option<Unit>) -> String {
|
||||
match format_duration_unit(duration, unit) {
|
||||
(duration_fmt, _) => duration_fmt,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn format_duration_unit(duration: Second, unit: Unit) -> (String, Unit) {
|
||||
if (duration < 1.0 && unit == Unit::Auto) || unit == Unit::MilliSecond {
|
||||
(format!("{:5.1} ms", duration * 1e3), Unit::MilliSecond)
|
||||
/// Like `format_duration`, but returns the target unit as well.
|
||||
pub fn format_duration_unit(duration: Second, unit: Option<Unit>) -> (String, Unit) {
|
||||
if (duration < 1.0 && unit.is_none()) || unit == Some(Unit::MilliSecond) {
|
||||
(format!("{:.1} ms", duration * 1e3), Unit::MilliSecond)
|
||||
} else {
|
||||
(format!("{:5.3} s", duration), Unit::Second)
|
||||
(format!("{:.3} s", duration), Unit::Second)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_duration_unit_basic() {
|
||||
let (out_str, out_unit) = format_duration_unit(1.3, None);
|
||||
|
||||
assert_eq!("1.300 s", out_str);
|
||||
assert_eq!(Unit::Second, out_unit);
|
||||
|
||||
let (out_str, out_unit) = format_duration_unit(1.0, None);
|
||||
|
||||
assert_eq!("1.000 s", out_str);
|
||||
assert_eq!(Unit::Second, out_unit);
|
||||
|
||||
let (out_str, out_unit) = format_duration_unit(0.999, None);
|
||||
|
||||
assert_eq!("999.0 ms", out_str);
|
||||
assert_eq!(Unit::MilliSecond, out_unit);
|
||||
|
||||
let (out_str, out_unit) = format_duration_unit(0.0, None);
|
||||
|
||||
assert_eq!("0.0 ms", out_str);
|
||||
assert_eq!(Unit::MilliSecond, out_unit);
|
||||
|
||||
let (out_str, out_unit) = format_duration_unit(1000.0, None);
|
||||
|
||||
assert_eq!("1000.000 s", out_str);
|
||||
assert_eq!(Unit::Second, out_unit);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_duration_unit_with_unit() {
|
||||
let (out_str, out_unit) = format_duration_unit(1.3, Some(Unit::Second));
|
||||
|
||||
assert_eq!("1.300 s", out_str);
|
||||
assert_eq!(Unit::Second, out_unit);
|
||||
|
||||
let (out_str, out_unit) = format_duration_unit(1.3, Some(Unit::MilliSecond));
|
||||
|
||||
assert_eq!("1300.0 ms", out_str);
|
||||
assert_eq!(Unit::MilliSecond, out_unit);
|
||||
}
|
||||
+56
-36
@@ -1,5 +1,3 @@
|
||||
use std::fmt;
|
||||
|
||||
use indicatif::{ProgressBar, ProgressStyle};
|
||||
|
||||
/// Type alias for unit of time
|
||||
@@ -8,6 +6,26 @@ pub type Second = f64;
|
||||
/// Threshold for warning about fast execution time
|
||||
pub const MIN_EXECUTION_TIME: Second = 5e-3;
|
||||
|
||||
/// Action to take when an executed command fails.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum CmdFailureAction {
|
||||
/// Exit with an error message
|
||||
RaiseError,
|
||||
|
||||
/// Simply ignore the non-zero exit code
|
||||
Ignore,
|
||||
}
|
||||
|
||||
/// Output style type option
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum OutputStyleOption {
|
||||
/// Do not output with colors or any special formatting
|
||||
Basic,
|
||||
|
||||
/// Output with full color and formatting
|
||||
Full,
|
||||
}
|
||||
|
||||
/// A set of options for hyperfine
|
||||
pub struct HyperfineOptions {
|
||||
/// Number of warmup runs
|
||||
@@ -20,7 +38,13 @@ pub struct HyperfineOptions {
|
||||
pub min_time_sec: Second,
|
||||
|
||||
/// Whether or not to ignore non-zero exit codes
|
||||
pub ignore_failure: bool,
|
||||
pub failure_action: CmdFailureAction,
|
||||
|
||||
/// Command to run before each timing run
|
||||
pub preparation_command: Option<String>,
|
||||
|
||||
/// What color mode to use for output
|
||||
pub output_style: OutputStyleOption,
|
||||
}
|
||||
|
||||
impl Default for HyperfineOptions {
|
||||
@@ -29,56 +53,52 @@ impl Default for HyperfineOptions {
|
||||
warmup_count: 0,
|
||||
min_runs: 10,
|
||||
min_time_sec: 3.0,
|
||||
ignore_failure: false,
|
||||
failure_action: CmdFailureAction::RaiseError,
|
||||
preparation_command: None,
|
||||
output_style: OutputStyleOption::Full,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Return a pre-configured progress bar
|
||||
pub fn get_progress_bar(length: u64, msg: &str) -> ProgressBar {
|
||||
let progressbar_style = ProgressStyle::default_spinner()
|
||||
.tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏")
|
||||
.template(" {spinner} {msg:<30} {wide_bar} ETA {eta_precise}");
|
||||
pub fn get_progress_bar(length: u64, msg: &str, option: &OutputStyleOption) -> ProgressBar {
|
||||
let progressbar_style = match *option {
|
||||
OutputStyleOption::Basic => ProgressStyle::default_bar(),
|
||||
OutputStyleOption::Full => ProgressStyle::default_spinner()
|
||||
.tick_chars("⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏")
|
||||
.template(" {spinner} {msg:<30} {wide_bar} ETA {eta_precise}"),
|
||||
};
|
||||
|
||||
let bar = ProgressBar::new(length);
|
||||
bar.set_style(progressbar_style.clone());
|
||||
bar.enable_steady_tick(80);
|
||||
bar.set_message(msg);
|
||||
let progress_bar = match *option {
|
||||
OutputStyleOption::Basic => ProgressBar::hidden(),
|
||||
OutputStyleOption::Full => ProgressBar::new(length),
|
||||
};
|
||||
progress_bar.set_style(progressbar_style.clone());
|
||||
progress_bar.enable_steady_tick(80);
|
||||
progress_bar.set_message(msg);
|
||||
|
||||
bar
|
||||
}
|
||||
|
||||
/// Possible benchmark warnings
|
||||
pub enum Warnings {
|
||||
FastExecutionTime,
|
||||
NonZeroExitCode,
|
||||
}
|
||||
|
||||
impl fmt::Display for Warnings {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
&Warnings::FastExecutionTime => write!(
|
||||
f,
|
||||
"Command took less than {:.0} ms to complete. Results might be inaccurate.",
|
||||
MIN_EXECUTION_TIME * 1e3
|
||||
),
|
||||
&Warnings::NonZeroExitCode => write!(f, "Ignoring non-zero exit code."),
|
||||
}
|
||||
}
|
||||
progress_bar
|
||||
}
|
||||
|
||||
/// A max function for f64's without NaNs
|
||||
pub fn max(vals: &[f64]) -> f64 {
|
||||
vals.iter()
|
||||
*vals.iter()
|
||||
.max_by(|a, b| a.partial_cmp(b).unwrap())
|
||||
.unwrap()
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// A min function for f64's without NaNs
|
||||
pub fn min(vals: &[f64]) -> f64 {
|
||||
vals.iter()
|
||||
*vals.iter()
|
||||
.min_by(|a, b| a.partial_cmp(b).unwrap())
|
||||
.unwrap()
|
||||
.clone()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_max() {
|
||||
assert_eq!(1.0, max(&[1.0]));
|
||||
assert_eq!(-1.0, max(&[-1.0]));
|
||||
assert_eq!(-1.0, max(&[-2.0, -1.0]));
|
||||
assert_eq!(1.0, max(&[-1.0, 1.0]));
|
||||
assert_eq!(1.0, max(&[-1.0, 1.0, 0.0]));
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
pub mod benchmark;
|
||||
pub mod format;
|
||||
pub mod internal;
|
||||
pub mod cputime;
|
||||
pub mod outlier_detection;
|
||||
pub mod warnings;
|
||||
@@ -0,0 +1,102 @@
|
||||
/// A module for statistical outlier detection.
|
||||
///
|
||||
/// References:
|
||||
/// - Boris Iglewicz and David Hoaglin (1993), "Volume 16: How to Detect and Handle Outliers",
|
||||
/// The ASQC Basic References in Quality Control: Statistical Techniques, Edward F. Mykytka,
|
||||
/// Ph.D., Editor.
|
||||
|
||||
use statistical::median;
|
||||
|
||||
/// Minimum modified Z-score for a datapoint to be an outlier. Here, 1.4826 is a factor that
|
||||
/// converts the MAD to an estimator for the standard deviation. The second factor is the number
|
||||
/// of standard deviations.
|
||||
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 average deviation.
|
||||
///
|
||||
/// References:
|
||||
/// - <https://en.wikipedia.org/wiki/Median_absolute_deviation>
|
||||
pub fn modified_zscores(xs: &[f64]) -> Vec<f64> {
|
||||
assert!(!xs.is_empty());
|
||||
|
||||
// Compute sample median:
|
||||
let x_median = median(xs);
|
||||
|
||||
// Compute the absolute deviations from the median:
|
||||
let deviations: Vec<f64> = xs.iter().map(|x| (x - x_median).abs()).collect();
|
||||
|
||||
// Compute median absolute deviation:
|
||||
let mad = median(&deviations);
|
||||
|
||||
// Compute modified Z-scores (x_i - x_median) / MAD
|
||||
xs.iter().map(|&x| (x - x_median) / mad).collect()
|
||||
}
|
||||
|
||||
/// Return the number of outliers in a given sample. Outliers are defined as data points with a
|
||||
/// modified Z-score that is larger than `OUTLIER_THRESHOLD`.
|
||||
#[cfg(test)]
|
||||
pub fn num_outliers(xs: &[f64]) -> usize {
|
||||
if xs.is_empty() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
let scores = modified_zscores(xs);
|
||||
scores
|
||||
.iter()
|
||||
.filter(|&&s| s.abs() > OUTLIER_THRESHOLD)
|
||||
.count()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_detect_outliers() {
|
||||
// Should not detect outliers in small samples
|
||||
assert_eq!(0, num_outliers(&[]));
|
||||
assert_eq!(0, num_outliers(&[50.0]));
|
||||
assert_eq!(0, num_outliers(&[1000.0, 0.0]));
|
||||
|
||||
// Should not detect outliers in low-variance samples
|
||||
let xs = [-0.2, 0.0, 0.2];
|
||||
assert_eq!(0, num_outliers(&xs));
|
||||
|
||||
// Should detect a single outlier
|
||||
let xs = [-0.2, 0.0, 0.2, 4.0];
|
||||
assert_eq!(1, num_outliers(&xs));
|
||||
|
||||
// Should detect a single outlier
|
||||
let xs = [0.5, 0.30, 0.29, 0.31, 0.30];
|
||||
assert_eq!(1, num_outliers(&xs));
|
||||
|
||||
// Should detect no outliers in sample drawn from normal distribution
|
||||
let xs = [
|
||||
2.33269488,
|
||||
1.42195907,
|
||||
-0.57527698,
|
||||
-0.31293437,
|
||||
2.2948158,
|
||||
0.75813273,
|
||||
-1.0712388,
|
||||
-0.96394741,
|
||||
-1.15897446,
|
||||
1.10976285,
|
||||
];
|
||||
assert_eq!(0, num_outliers(&xs));
|
||||
|
||||
// Should detect two outliers that were manually added
|
||||
let xs = [
|
||||
2.33269488,
|
||||
1.42195907,
|
||||
-0.57527698,
|
||||
-0.31293437,
|
||||
2.2948158,
|
||||
0.75813273,
|
||||
-1.0712388,
|
||||
-0.96394741,
|
||||
-1.15897446,
|
||||
1.10976285,
|
||||
20.0,
|
||||
-500.0,
|
||||
];
|
||||
assert_eq!(2, num_outliers(&xs));
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
use std::fmt;
|
||||
|
||||
use hyperfine::internal::{Second, MIN_EXECUTION_TIME};
|
||||
use hyperfine::format::format_duration;
|
||||
|
||||
/// A list of all possible warnings
|
||||
pub enum Warnings {
|
||||
FastExecutionTime,
|
||||
NonZeroExitCode,
|
||||
SlowInitialRun(Second),
|
||||
OutliersDetected,
|
||||
}
|
||||
|
||||
impl fmt::Display for Warnings {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
Warnings::FastExecutionTime => write!(
|
||||
f,
|
||||
"Command took less than {:.0} ms to complete. Results might be inaccurate.",
|
||||
MIN_EXECUTION_TIME * 1e3
|
||||
),
|
||||
Warnings::NonZeroExitCode => write!(f, "Ignoring non-zero exit code."),
|
||||
Warnings::SlowInitialRun(t_first) => write!(
|
||||
f,
|
||||
"The first benchmarking run for this command was significantly slower than the \
|
||||
rest ({}). This could be caused by (filesystem) caches that were not filled until \
|
||||
after the first run. You should consider using the '--warmup' option to fill \
|
||||
those caches before the actual benchmark. Alternatively, use the '--prepare' \
|
||||
option to clear the caches before each timing run.",
|
||||
format_duration(t_first, None)
|
||||
),
|
||||
Warnings::OutliersDetected => write!(
|
||||
f,
|
||||
"Statistical outliers were detected. Consider re-running this benchmark on a quiet \
|
||||
PC without any interferences from other programs. It might help to use the \
|
||||
'--warmup' or '--prepare' options."
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
+82
-18
@@ -1,45 +1,64 @@
|
||||
extern crate ansi_term;
|
||||
extern crate atty;
|
||||
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
extern crate colored;
|
||||
extern crate indicatif;
|
||||
extern crate libc;
|
||||
extern crate statistical;
|
||||
|
||||
#[cfg(test)]
|
||||
#[macro_use]
|
||||
extern crate approx;
|
||||
|
||||
use std::cmp;
|
||||
use std::error::Error;
|
||||
use std::io;
|
||||
|
||||
use ansi_term::Colour::Red;
|
||||
use atty::Stream;
|
||||
use colored::*;
|
||||
use clap::{App, AppSettings, Arg};
|
||||
|
||||
mod hyperfine;
|
||||
|
||||
use hyperfine::internal::HyperfineOptions;
|
||||
use hyperfine::internal::{CmdFailureAction, HyperfineOptions, OutputStyleOption};
|
||||
use hyperfine::benchmark::{mean_shell_spawning_time, run_benchmark};
|
||||
|
||||
/// Print error message to stderr and terminate
|
||||
pub fn error(message: &str) -> ! {
|
||||
eprintln!("{}: {}", Red.paint("Error"), message);
|
||||
eprintln!("{} {}", "Error:".red(), message);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
/// Runs the benchmark for the given commands
|
||||
fn run(commands: &Vec<&str>, options: &HyperfineOptions) -> io::Result<()> {
|
||||
let shell_spawning_time = mean_shell_spawning_time()?;
|
||||
let shell_spawning_time = mean_shell_spawning_time(&options.output_style)?;
|
||||
|
||||
// Run the benchmarks
|
||||
for (num, cmd) in commands.iter().enumerate() {
|
||||
run_benchmark(num, &cmd, shell_spawning_time, &options)?;
|
||||
run_benchmark(num, cmd, shell_spawning_time, options)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Process command line options
|
||||
let mut options = HyperfineOptions::default();
|
||||
|
||||
let clap_color_setting = if atty::is(Stream::Stdout) {
|
||||
AppSettings::ColoredHelp
|
||||
} else {
|
||||
AppSettings::ColorNever
|
||||
};
|
||||
|
||||
let matches = App::new("hyperfine")
|
||||
.version(crate_version!())
|
||||
.setting(AppSettings::ColoredHelp)
|
||||
.setting(clap_color_setting)
|
||||
.setting(AppSettings::DeriveDisplayOrder)
|
||||
.about("A command-line benchmarking tool")
|
||||
.setting(AppSettings::UnifiedHelpMessage)
|
||||
.max_term_width(90)
|
||||
.about("A command-line benchmarking tool.")
|
||||
.arg(
|
||||
Arg::with_name("command")
|
||||
.help("Command to benchmark")
|
||||
@@ -53,7 +72,10 @@ fn main() {
|
||||
.short("w")
|
||||
.takes_value(true)
|
||||
.value_name("NUM")
|
||||
.help("Perform NUM warmup runs before the actual benchmark"),
|
||||
.help(
|
||||
"Perform NUM warmup runs before the actual benchmark. This can be used \
|
||||
to fill (disk) caches for I/O-heavy programs.",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("min-runs")
|
||||
@@ -61,21 +83,47 @@ fn main() {
|
||||
.short("m")
|
||||
.takes_value(true)
|
||||
.value_name("NUM")
|
||||
.help("Perform at least NUM runs for each command"),
|
||||
.help(&format!(
|
||||
"Perform at least NUM runs for each command (default: {}).",
|
||||
options.min_runs
|
||||
)),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("prepare")
|
||||
.long("prepare")
|
||||
.short("p")
|
||||
.takes_value(true)
|
||||
.value_name("CMD")
|
||||
.help(
|
||||
"Execute CMD before each timing run. This is useful for \
|
||||
clearing disk caches, for example.",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("style")
|
||||
.long("style")
|
||||
.short("s")
|
||||
.takes_value(true)
|
||||
.value_name("TYPE")
|
||||
.possible_values(&["auto", "basic", "full"])
|
||||
.help(
|
||||
"Set output style type (default: auto). Set this to 'basic' to disable output \
|
||||
coloring and interactive elements. Set it to 'full' to enable all effects \
|
||||
even if no interactive terminal was detected.",
|
||||
),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("ignore-failure")
|
||||
.long("ignore-failure")
|
||||
.short("i")
|
||||
.help("Ignore non-zero exit codes"),
|
||||
.help("Ignore non-zero exit codes."),
|
||||
)
|
||||
.help_message("Print this help message.")
|
||||
.version_message("Show version information.")
|
||||
.get_matches();
|
||||
|
||||
let str_to_u64 = |n| u64::from_str_radix(n, 10).ok();
|
||||
|
||||
// Process command line options
|
||||
let mut options = HyperfineOptions::default();
|
||||
|
||||
options.warmup_count = matches
|
||||
.value_of("warmup")
|
||||
.and_then(&str_to_u64)
|
||||
@@ -86,13 +134,29 @@ fn main() {
|
||||
options.min_runs = cmp::max(2, min_runs);
|
||||
}
|
||||
|
||||
options.ignore_failure = matches.is_present("ignore-failure");
|
||||
options.preparation_command = matches.value_of("prepare").map(String::from);
|
||||
|
||||
options.output_style = match matches.value_of("style") {
|
||||
Some("full") => OutputStyleOption::Full,
|
||||
Some("basic") => OutputStyleOption::Basic,
|
||||
_ => if atty::is(Stream::Stdout) {
|
||||
OutputStyleOption::Full
|
||||
} else {
|
||||
OutputStyleOption::Basic
|
||||
},
|
||||
};
|
||||
|
||||
if options.output_style == OutputStyleOption::Basic {
|
||||
colored::control::set_override(false);
|
||||
}
|
||||
if matches.is_present("ignore-failure") {
|
||||
options.failure_action = CmdFailureAction::Ignore;
|
||||
}
|
||||
|
||||
let commands = matches.values_of("command").unwrap().collect();
|
||||
let res = run(&commands, &options);
|
||||
|
||||
match res {
|
||||
Err(e) => error(e.description()),
|
||||
Ok(_) => {}
|
||||
if let Err(e) = res {
|
||||
error(e.description());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user