mirror of
https://github.com/sharkdp/hyperfine.git
synced 2024-10-26 14:10:51 +03:00
Compare commits
5 Commits
5493cf5039
...
c0921351e7
Author | SHA1 | Date | |
---|---|---|---|
|
c0921351e7 | ||
|
865b496098 | ||
|
51d056a3de | ||
|
836d1730b5 | ||
|
5c9d7a8b1e |
13
README.md
13
README.md
@ -16,15 +16,14 @@ A special *thank you* goes to our biggest <a href="doc/sponsors.md">sponsor</a>:
|
||||
|
||||
<a href="https://bencher.dev/hyperfine/?utm_source=github&utm_medium=referral&utm_campaign=hyperfine&utm_content=wordmark">
|
||||
<img src="doc/sponsors/bencher_wordmark.svg" width="200" alt="🐰 Bencher">
|
||||
<br>
|
||||
<br />
|
||||
<strong>Continuous Benchmarking: Catch performance regressions in CI</strong>
|
||||
</a>
|
||||
<br>
|
||||
<a href="https://bencher.dev/hyperfine/?utm_source=github&utm_medium=referral&utm_campaign=hyperfine&utm_content=copy">
|
||||
<sub>Track the results of your <code>hyperfine</code> benchmarks over time with Bencher.</sub>
|
||||
<br>
|
||||
<sup>Detect and prevent performance regressions before they make it to production.</sup>
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
Track the results of your <code>hyperfine</code> benchmarks over time with Bencher. \
|
||||
Detect and prevent performance regressions before they make it to production.
|
||||
|
||||
## Features
|
||||
|
||||
|
@ -15,6 +15,7 @@ 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("--sort-by", choices=['median'], help="Sort method")
|
||||
parser.add_argument(
|
||||
"--labels", help="Comma-separated list of entries for the plot legend"
|
||||
)
|
||||
@ -24,7 +25,7 @@ parser.add_argument(
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
with open(args.file) as f:
|
||||
with open(args.file, encoding='utf-8') as f:
|
||||
results = json.load(f)["results"]
|
||||
|
||||
if args.labels:
|
||||
@ -33,6 +34,13 @@ else:
|
||||
labels = [b["command"] for b in results]
|
||||
times = [b["times"] for b in results]
|
||||
|
||||
if args.sort_by == 'median':
|
||||
medians = [b["median"] for b in results]
|
||||
indices = sorted(range(len(labels)), key=lambda k: medians[k])
|
||||
labels = [labels[i] for i in indices]
|
||||
times = [times[i] for i in indices]
|
||||
|
||||
plt.figure(figsize=(10, 6), constrained_layout=True)
|
||||
boxplot = plt.boxplot(times, vert=True, patch_artist=True)
|
||||
cmap = plt.get_cmap("rainbow")
|
||||
colors = [cmap(val / len(times)) for val in range(len(times))]
|
||||
@ -45,6 +53,7 @@ if args.title:
|
||||
plt.legend(handles=boxplot["boxes"], labels=labels, loc="best", fontsize="medium")
|
||||
plt.ylabel("Time [s]")
|
||||
plt.ylim(0, None)
|
||||
plt.xticks(list(range(1, len(labels)+1)), labels, rotation=45)
|
||||
if args.output:
|
||||
plt.savefig(args.output)
|
||||
else:
|
||||
|
@ -59,11 +59,11 @@ impl<'a> Command<'a> {
|
||||
}
|
||||
|
||||
pub fn get_name_with_unused_parameters(&self) -> String {
|
||||
let parameters =
|
||||
self.get_unused_parameters()
|
||||
.fold(String::new(), |output, (parameter, value)| {
|
||||
output + &format!("{} = {}, ", parameter, value.to_string())
|
||||
});
|
||||
let parameters = self
|
||||
.get_unused_parameters()
|
||||
.fold(String::new(), |output, (parameter, value)| {
|
||||
output + &format!("{} = {}, ", parameter, value)
|
||||
});
|
||||
let parameters = parameters.trim_end_matches(", ");
|
||||
let parameters = if parameters.is_empty() {
|
||||
"".into()
|
||||
|
@ -1,4 +1,5 @@
|
||||
use crate::util::number::Number;
|
||||
use std::fmt::Display;
|
||||
|
||||
pub mod range_step;
|
||||
pub mod tokenize;
|
||||
@ -9,12 +10,13 @@ pub enum ParameterValue {
|
||||
Numeric(Number),
|
||||
}
|
||||
|
||||
impl ToString for ParameterValue {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
impl Display for ParameterValue {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let str = match self {
|
||||
ParameterValue::Text(ref value) => value.clone(),
|
||||
ParameterValue::Numeric(value) => value.to_string(),
|
||||
}
|
||||
};
|
||||
write!(f, "{}", str)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
use std::iter::Iterator;
|
||||
|
||||
/// A max function for f64's without NaNs
|
||||
pub fn max(vals: &[f64]) -> f64 {
|
||||
*vals
|
||||
|
Loading…
Reference in New Issue
Block a user