Benchmarking Raspi Input/Output

Yo, so this one counts for checking the GPIO response of Raspberry pi.

What it means ?

How much it takes of a Raspi to give a response on GPIO when trigger action is received on another GPIO.

How am  I doing this ?

I have this setup of an Arduino connected to Raspi GPIO on pin 7 and 8.
Another green arduino board is for getting serial terminal of Raspberry pi.
raspi_benching

Raspi GPIO 7 (set as output) —> Arduino pin 13
Raspi GPIO 8 (set as input  ) —> Arduino pin 12

Open up arduino IDE and write a simple program to give a little pulse on pin 12 of Arduino which is connected to GPIO 8 of Raspi.

int output_pin=12;

void setup()

{
pinMode(output_pin,OUTPUT);
}

void loop()
{
digitalWrite(12,HIGH);
delay(10);
digitalWrite(12,LOW);
delay(1000);
}

Upload the sketch onto your arduino.

So, I am testing this via two simplest possible ways, i.e

1. Using Shell Script

#!/bin/bash

echo 7 > /sys/class/gpio/export
echo 8 > /sys/class/gpio/export

echo out > /sys/class/gpio/gpio7/direction
echo in > /sys/class/gpio/gpio8/direction

while true
do
x=$(cat /sys/class/gpio/gpio8/value)
if [ $x = 1 ]
then
echo 1 > /sys/class/gpio/gpio7/value
else
echo 0 > /sys/class/gpio/gpio7/value
fi
done

Now, open up the Saleae Analyzer and lets check the response, Here is what I got:

benchmark_1

 

So, raspi took 2.5 miliseconds to give the output on the pin for rising edge.

2.  Using Python based GPIO library:

#!/usr/bin/env python
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(7,GPIO.OUT)
GPIO.setup(8,GPIO.IN)

while True:
if GPIO.input(8):
GPIO.output(7,1)
else:
GPIO.output(7,0)

 

And probing on the pins, here is what I got :

benchmark_2

Look at the response time, 11.125 micro secods!!!

Hell yeah! this is all the way too good for my work.  Even though this is not as good as AVR using avr IO library but I guess works for quite a lot things in use.

 

Assumptions :
All the processes are working as normal as they do.  I have not deliberately changed the nice value of my shell script AND/OR python script.

No sleep is given in both the while loops INTENTIONALLY

I did the above on the my raspi with following config :
pi@raspberrypi:~$ uname -a
Linux raspberrypi 3.12.35+ #730 PREEMPT Fri Dec 19 18:31:24 GMT 2014 armv6l GNU/Linux

Overclocking : None   700MHz ARM, 250MHz core, 400MHz SDRAM, 0 overvolt