hybridgroup.gobot/system/digitalpin_bench_test.go

25 lines
385 B
Go
Raw Normal View History

2022-11-21 02:22:26 +08:00
package system
2022-10-27 00:21:34 +08:00
import (
"testing"
)
func BenchmarkDigitalRead(b *testing.B) {
2022-11-05 14:42:28 +08:00
a := NewAccesser()
mockPaths := []string{
"/sys/class/gpio/export",
"/sys/class/gpio/unexport",
"/sys/class/gpio/gpio10/value",
"/sys/class/gpio/gpio10/direction",
2022-11-05 14:42:28 +08:00
}
a.UseMockFilesystem(mockPaths)
2022-10-27 00:21:34 +08:00
pin := a.NewDigitalPin("", 10)
pin.Write(1)
for i := 0; i < b.N; i++ {
pin.Read()
}
}