Quantcast
Channel: Oracle Bloggers
Viewing all articles
Browse latest Browse all 19780

RPi with an Oscilloscope and Java Embedded: Ready for Benchmarking (Part 3)

$
0
0
The first step in our investigation is to reproduce what Robert Savage saw in his benchmarking. See: Java GPIO Benchmarking

In his study, Robert Savage measured the Pi4J library on Oracle Java JDK 8 Preview for Linux/ARM yielding about 153 kHz on the Raspberry Pi GPIO output. So, following the scientific method, we should be able to reproduce the experiment.

And, with the following Java Embedded app on my RPi running with Oracle JDK 8 Preview for Linux/ARM and using my HP logic analyzer/oscilloscope I'm seeing about the same: 166 kHz. Click on the above photo to zoom in and look at the red circle area.

Here's the code I used:

/*
 * Example Code
 */

/*** Pi4J Core APIs ***/
import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;

//...
            
 /*** Pi4J initialization ***/
 
 // Create Pi4J GPIO Controller
 final GpioController gpio = GpioFactory.getInstance();
        
 // Use Pi4J GPIO pin #05 (Header Pin #18) as an output and turn on
 final GpioPinDigitalOutput pin = 
         gpio.provisionDigitalOutputPin(RaspiPin.GPIO_05, 
         PinState.LOW);
 
 // Loop forever to create smallest PWM as possible
 while (true) {          
     pin.setState(true);
     pin.setState(false);
 }
 

And, Robert reports he can get around 5 MHz using C native. So, that's our goal. In the next blog posts we'll explore ways to get our 166 kHz score on the benchmark a lot higher, hopefully matching C native with 5 MHz...


Viewing all articles
Browse latest Browse all 19780

Trending Articles