Benchmark related changes

- .gohci.yml: Run with both -cover and -bench on odroid and win10 and make the
  benchtime 1000ms instead of 10ms to increase precision, as this was lacking.
- apa102: add benchmark for toRGBFast()
- bmxx80: add benchmark for conversion functions.
- gpiotest: silence test (was leaking output during benchmarks)
- physic: add benchmark for the current int64 String() implementation compared
  to an hypothetical (simpler) float64 based implementation.
pull/1/head
Marc-Antoine Ruel 8 years ago
parent 66af77a36a
commit f15a60524d

@ -15,3 +15,11 @@ func TestToRGBFast_limits(t *testing.T) {
t.Fatal(r, g, b) t.Fatal(r, g, b)
} }
} }
func BenchmarkToRGBFast(b *testing.B) {
for i := 0; i < b.N; i++ {
if r, g, blue := toRGBFast(30000); r != 159 || g != 191 || blue != 255 {
b.FailNow()
}
}
}

@ -805,6 +805,48 @@ func TestCalibration280_compensateHumidityInt(t *testing.T) {
} }
} }
func BenchmarkCalibration280Int32(b *testing.B) {
tRaw := int32(524112)
pRaw := int32(309104)
hRaw := int32(30987)
for i := 0; i < b.N; i++ {
temp, tFine := calib280.compensateTempInt(tRaw)
pres := calib280.compensatePressureInt32(pRaw, tFine)
humi := calib280.compensateHumidityInt(hRaw, tFine)
if tFine != 117407 || temp != 2293 || pres != 100045 || humi != 64686 {
b.FailNow()
}
}
}
func BenchmarkCalibration280Int64(b *testing.B) {
tRaw := int32(524112)
pRaw := int32(309104)
hRaw := int32(30987)
for i := 0; i < b.N; i++ {
temp, tFine := calib280.compensateTempInt(tRaw)
pres := calib280.compensatePressureInt64(pRaw, tFine)
humi := calib280.compensateHumidityInt(hRaw, tFine)
if tFine != 117407 || temp != 2293 || pres != 25611063 || humi != 64686 {
b.FailNow()
}
}
}
func BenchmarkCalibration280Float64(b *testing.B) {
tRaw := int32(524112)
pRaw := int32(309104)
hRaw := int32(30987)
for i := 0; i < b.N; i++ {
temp, tFine := calib280.compensateTempFloat(tRaw)
pres := calib280.compensatePressureFloat(pRaw, tFine)
humi := calib280.compensateHumidityFloat(hRaw, tFine)
if tFine != 117494 || !floatEqual(temp, 22.948120) || !floatEqual(pres, 100.046074) || !floatEqual(humi, 63.167889) {
b.FailNow()
}
}
}
// //
var epsilon float32 = 0.00000001 var epsilon float32 = 0.00000001

Loading…
Cancel
Save