1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
//
// Copyright (c) 2015-2024 MinIO, Inc.
//
// This file is part of MinIO Object Storage stack
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package madmin
import (
"sort"
"testing"
)
func TestTimings(t *testing.T) {
durations := TimeDurations{
4000000,
4000000,
9000000,
9000000,
12000000,
12000000,
14000000,
14000000,
17000000,
17000000,
21000000,
21000000,
36000000,
36000000,
37000000,
37000000,
42000000,
42000000,
54000000,
54000000,
67000000,
67000000,
77000000,
77000000,
88000000,
88000000,
89000000,
89000000,
93000000,
93000000,
}
sort.Slice(durations, func(i, j int) bool {
return int64(durations[i]) < int64(durations[j])
})
timings := durations.Measure()
if timings.Avg != 44000000 {
t.Errorf("Expected 44000000, got %d\n", timings.Avg)
}
if timings.P50 != 37000000 {
t.Errorf("Expected 37000000, got %d\n", timings.P50)
}
if timings.P75 != 77000000 {
t.Errorf("Expected 77000000, got %d\n", timings.P75)
}
if timings.P95 != 93000000 {
t.Errorf("Expected 93000000, got %d\n", timings.P95)
}
if timings.P99 != 93000000 {
t.Errorf("Expected 93000000, got %d\n", timings.P99)
}
if timings.P999 != 93000000 {
t.Errorf("Expected 93000000, got %d\n", timings.P999)
}
if timings.Long5p != 93000000 {
t.Errorf("Expected 93000000, got %d\n", timings.Long5p)
}
if timings.Short5p != 4000000 {
t.Errorf("Expected 4000000, got %d\n", timings.Short5p)
}
if timings.Max != 93000000 {
t.Errorf("Expected 93000000, got %d\n", timings.Max)
}
if timings.Min != 4000000 {
t.Errorf("Expected 4000000, got %d\n", timings.Min)
}
if timings.Range != 89000000 {
t.Errorf("Expected 89000000, got %d\n", timings.Range)
}
if timings.StdDev != 30772281 {
t.Errorf("Expected abc, got %d\n", timings.StdDev)
}
}
|