mattjlewis / diozero

Java Device I/O library that is portable across Single Board Computers and microcontrollers. Tested with Raspberry Pi, Odroid C2, BeagleBone Black, Next Thing CHIP, Asus Tinker Board and Arduinos / Pico. Supports GPIO, I2C, SPI as well as Serial communication. Also known to work with Udoo Quad.
https://www.diozero.com
MIT License
261 stars 59 forks source link

Performance tests not accurate #110

Closed sgjava closed 1 year ago

sgjava commented 1 year ago

Using NanoPi Duo, Armbian and JDK 17 I run:

sudo java -cp $HOME/diozero-distribution-1.3.4/diozero-sampleapps-1.3.4.jar com.diozero.sampleapps.perf.MmapGpioPerfTest 203 10000000

18:15:37.043 [main] INFO com.diozero.sampleapps.perf.MmapGpioPerfTest.test - Duration for 10,000,000 iterations: 4.034s, frequency: 2,478,929Hz
18:15:41.107 [main] INFO com.diozero.sampleapps.perf.MmapGpioPerfTest.test - Duration for 10,000,000 iterations: 3.998s, frequency: 2,501,251Hz
18:15:45.032 [main] INFO com.diozero.sampleapps.perf.MmapGpioPerfTest.test - Duration for 10,000,000 iterations: 3.921s, frequency: 2,550,370Hz
18:15:48.955 [main] INFO com.diozero.sampleapps.perf.MmapGpioPerfTest.test - Duration for 10,000,000 iterations: 3.92s, frequency: 2,551,020Hz
18:15:52.880 [main] INFO com.diozero.sampleapps.perf.MmapGpioPerfTest.test - Duration for 10,000,000 iterations: 3.92s, frequency: 2,551,020Hz

MmapGpioPerfTest shows 2.5 MHz, but on oscilloscope it's actually 556 KHz. Same results with GpioPerfTest.