Account for floating point inaccuracy in histogram calculation
Dependencies
- [2]
ZEN3WUPDAdd support for histogram charts
Change contents
- edit in src/visualize/histogram.rs at line 6
const DECIMAL_PLACES: usize = 50; - replacement in src/visualize/histogram.rs at line 60
assert_eq!(next_multiple, next_multiple.floor());let bucket_index = next_multiple as usize;let float_error_margin = 2_f64.powf(1_f64 - (DECIMAL_PLACES as f64));assert!((next_multiple - next_multiple.round()).abs() <= float_error_margin);// assert_eq!(next_multiple, next_multiple.round());let bucket_index = (next_multiple.round()) as usize; - replacement in src/visualize/histogram.rs at line 66
buckets[bucket_index] += 1;if bucket_index == BUCKET_COUNT {// The max duration should be the only one in this final bucketassert_eq!(duration, max_duration);buckets[bucket_index - 1] += 1;} else {// Every other duration should hit this case insteadbuckets[bucket_index] += 1;}