@@ -84,6 +84,8 @@ func TestAggregates(t *testing.T) {
8484 Fifty : 1000 ,
8585 Ninety : 1000 ,
8686 NinetyFive : 1000 ,
87+ // Since cpu is calculated between samples, we lose 1 sample.
88+ Count : N - 2 ,
8789 }
8890 if usage .Cpu != cpuExpected {
8991 t .Errorf ("cpu stats are %+v. Expected %+v" , usage .Cpu , cpuExpected )
@@ -95,6 +97,7 @@ func TestAggregates(t *testing.T) {
9597 Fifty : 50 * 1024 ,
9698 Ninety : 90 * 1024 ,
9799 NinetyFive : 95 * 1024 ,
100+ Count : N - 1 ,
98101 }
99102 if usage .Memory != memExpected {
100103 t .Errorf ("memory stats are mean %+v. Expected %+v" , usage .Memory , memExpected )
@@ -133,6 +136,8 @@ func TestSamplesCloseInTimeIgnored(t *testing.T) {
133136 Fifty : 1000 ,
134137 Ninety : 1000 ,
135138 NinetyFive : 1000 ,
139+ // Since cpu is calculated between samples, we lose 1 sample.
140+ Count : N - 2 ,
136141 }
137142 if usage .Cpu != cpuExpected {
138143 t .Errorf ("cpu stats are %+v. Expected %+v" , usage .Cpu , cpuExpected )
@@ -144,6 +149,7 @@ func TestSamplesCloseInTimeIgnored(t *testing.T) {
144149 Fifty : 50 * 1024 ,
145150 Ninety : 90 * 1024 ,
146151 NinetyFive : 95 * 1024 ,
152+ Count : N - 1 ,
147153 }
148154 if usage .Memory != memExpected {
149155 t .Errorf ("memory stats are mean %+v. Expected %+v" , usage .Memory , memExpected )
@@ -184,6 +190,8 @@ func TestDerivedStats(t *testing.T) {
184190 Fifty : 50 * Nanosecond ,
185191 Ninety : 90 * Nanosecond ,
186192 NinetyFive : 95 * Nanosecond ,
193+ // GetDerivedPercentiles calculates directly from samples, hence we don't lose any samples.
194+ Count : N - 1 ,
187195 }
188196 if usage .Cpu != cpuExpected {
189197 t .Errorf ("cpu stats are %+v. Expected %+v" , usage .Cpu , cpuExpected )
@@ -195,6 +203,7 @@ func TestDerivedStats(t *testing.T) {
195203 Fifty : 50 * 1024 ,
196204 Ninety : 90 * 1024 ,
197205 NinetyFive : 95 * 1024 ,
206+ Count : N - 1 ,
198207 }
199208 if usage .Memory != memExpected {
200209 t .Errorf ("memory stats are mean %+v. Expected %+v" , usage .Memory , memExpected )
0 commit comments