2022-11-21 02:22:26 +08:00
|
|
|
package system
|
2016-02-19 04:08:48 +08:00
|
|
|
|
2022-10-27 00:21:34 +08:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
2016-02-19 04:08:48 +08:00
|
|
|
|
|
|
|
func BenchmarkDigitalRead(b *testing.B) {
|
2022-11-05 14:42:28 +08:00
|
|
|
a := NewAccesser()
|
|
|
|
mockPaths := []string{
|
2016-02-19 04:08:48 +08:00
|
|
|
"/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
|
|
|
|
2022-11-27 23:06:09 +08:00
|
|
|
pin := a.NewDigitalPin("", 10)
|
2016-02-19 04:08:48 +08:00
|
|
|
pin.Write(1)
|
|
|
|
|
|
|
|
for i := 0; i < b.N; i++ {
|
|
|
|
pin.Read()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|