Skip to content

Commit

Permalink
fix: bug that made some calculations wrong (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
blaze-form3 authored Sep 12, 2023
1 parent ed5db48 commit 52025dc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/trigger/gaussian/gaussian_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,5 @@ func parseRateToTPS(rateArg string) (float64, error) {
if err != nil {
return -1, fmt.Errorf("parse to tps %s: %w", rateArg, err)
}
return float64(rate) * unit.Seconds(), nil
return float64(rate) / unit.Seconds(), nil
}
26 changes: 25 additions & 1 deletion internal/trigger/gaussian/gaussian_rate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ func Test_calculateVolume(t *testing.T) {
want: 358629,
wantErr: false,
},
{
name: "10TPS 2",
peakTps: "100/10s",
stddev: 4 * time.Hour,
peakTime: 14 * time.Hour,
want: 358629,
wantErr: false,
},
{
name: "10TPS no unit",
peakTps: "10",
Expand All @@ -257,12 +265,28 @@ func Test_calculateVolume(t *testing.T) {
want: 358629,
wantErr: false,
},
{
name: "1TPms",
peakTps: "1/ms",
stddev: 4 * time.Hour,
peakTime: 14 * time.Hour,
want: 35862889,
wantErr: false,
},
{
name: "1000TPms",
peakTps: "1000/ms",
stddev: 4 * time.Hour,
peakTime: 14 * time.Hour,
want: 35863,
want: 35862888782,
wantErr: false,
},
{
name: "1TPH",
peakTps: "1/h",
stddev: 4 * time.Hour,
peakTime: 14 * time.Hour,
want: 10,
wantErr: false,
},
{
Expand Down

0 comments on commit 52025dc

Please sign in to comment.