Skip to content

Commit 7eaf227

Browse files
committed
perf_img
1 parent 102d2f9 commit 7eaf227

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

lib/bencher_plot/src/line.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
use std::sync::LazyLock;
2-
use std::{io::Cursor, ops::Range};
1+
use crate::PlotError;
32
use bencher_json::{project::perf::JsonPerfMetrics, JsonPerf};
43
use bencher_json::{JsonMeasure, Units};
54
use chrono::{DateTime, Duration, Utc};
65
use image::{GenericImageView, ImageBuffer};
76
use ordered_float::{FloatCore, OrderedFloat};
7+
use plotters::chart::{ChartContext, DualCoordChartContext};
8+
use plotters::coord::ranged1d::{DefaultFormatting, KeyPointHint};
9+
use plotters::prelude::{Cartesian2d, IntoLogRange, LogCoord, RangedDateTime};
810
use plotters::{
911
coord::{types::RangedCoordf64, Shift},
1012
prelude::{
@@ -14,10 +16,8 @@ use plotters::{
1416
series::LineSeries,
1517
style::{Color, FontFamily, RGBColor, ShapeStyle, WHITE},
1618
};
17-
use plotters::chart::{ChartContext, DualCoordChartContext};
18-
use plotters::coord::ranged1d::{DefaultFormatting, KeyPointHint};
19-
use plotters::prelude::{Cartesian2d, IntoLogRange, LogCoord, RangedDateTime};
20-
use crate::PlotError;
19+
use std::sync::LazyLock;
20+
use std::{io::Cursor, ops::Range};
2121

2222
const IMG_WIDTH: u32 = 1024;
2323
const IMG_HEIGHT: u32 = 768;
@@ -187,18 +187,15 @@ impl Ranged for RangedCoord {
187187

188188
impl From<Range<f64>> for RangedCoord {
189189
fn from(range: Range<f64>) -> Self {
190-
let relative_difference = if range.start == 0.0 {
191-
range.end
192-
} else {
190+
let relative_difference = if range.start.is_normal() {
193191
range.end / range.start
192+
} else {
193+
range.end
194194
};
195-
let use_log_scaling = relative_difference >= 10.0;
196-
if use_log_scaling {
197-
let range_coord: LogCoord<f64> = range.log_scale().into();
198-
RangedCoord::Log(range_coord)
195+
if relative_difference < 10.0 {
196+
RangedCoord::Linear(range.into())
199197
} else {
200-
let range_coord: RangedCoordf64 = range.into();
201-
RangedCoord::Linear(range_coord)
198+
RangedCoord::Log(range.log_scale().into())
202199
}
203200
}
204201
}
@@ -813,7 +810,8 @@ mod test {
813810

814811
pub const PERF_DUAL_AXES_DOT_JSON: &str = include_str!("../perf_dual_axes.json");
815812
static JSON_PERF_DUAL_AXES: LazyLock<JsonPerf> = LazyLock::new(|| {
816-
serde_json::from_str(PERF_DUAL_AXES_DOT_JSON).expect("Failed to serialize perf dual axes JSON")
813+
serde_json::from_str(PERF_DUAL_AXES_DOT_JSON)
814+
.expect("Failed to serialize perf dual axes JSON")
817815
});
818816

819817
pub const DECIMAL_DOT_JSON: &str = include_str!("../decimal.json");

services/console/src/chunks/docs-reference/changelog/en/changelog.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Pending `v0.5.0`
22
- Allow `bencher run` to create a project if it does not exist for both authenticated and anonymous users
3+
- Deprecate the `--no-hash` flag for `bencher run`
4+
- Add log scaling to Perf Images (Thank you [@brianheineman](https://github.com/brianheineman))
35

46
## `v0.4.37`
57
- Add dimension search in Threshold creation UI

0 commit comments

Comments
 (0)