libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
performance.py File Reference

Example: test execution speed of several methods to toggle a GPIO pin. More...

Go to the source code of this file.

Functions

def performance.FREQ (_N_)
 Macro to measure the frequency and compute statistics.
 
def performance.DIRECT (_O_)
 Macro to set output pin by fast direct PRU command (no error checking).
 

Variables

 performance.C_IN = P9_42
 The pin to use for CAP input.
 
 performance.GOUT = P8_16
 The pin to use for GPIO output.
 
 performance.G_IN = P8_14
 The pin to use for GPIO input.
 
list performance.desc
 Test descriptions. More...
 
 performance.f0 = c_float(0.)
 The current measurement result.
 
list performance.nf = [100e6,100e6,100e6,100e6,100e6,100e6,100e6]
 Array for minimal frequency (initialized high)
 
list performance.sf = [0.,0.,0.,0.,0.,0.,0.]
 Array for frequency.
 
list performance.xf = [0.,0.,0.,0.,0.,0.,0.]
 Array for maximal frequency.
 
 performance.r0 = c_ubyte(0)
 Input Gpio.
 
 performance.r1 = c_ubyte(0)
 Output Gpio.
 
 performance.m0 = c_ulong(0)
 Input bit mask.
 
 performance.m1 = c_ulong(0)
 Output bit mask.
 
 performance.ad = c_ulong(0)
 Adress of GPIO subsystem.
 
 performance.oe = c_ulong(0)
 Adress of Output Enable register in GPIO subsystem.
 
 performance.cd = c_ulong(0)
 Adress of Clear Data register in GPIO subsystem.
 
 performance.sd = c_ulong(0)
 Adress of Set Date register in GPIO subsystem.
 
 performance.io = pruio_new(PRUIO_DEF_ACTIVE, 4, 0x98, 0)
 Create a ctypes pointer to the pruio structure.
 
 performance.IO = io.contents
 The pointer dereferencing, using contents member.
 

Detailed Description

Example: test execution speed of several methods to toggle a GPIO pin.

This file contains an example on measuring the execution speed of different controllers that toggles a GPIO output. It measures the frequency of the toggled output from open and closed loop controllers and computes their mimimum, avarage and maximum execution speed. Find a functional description in section performance.

The code performs 50 tests of each controller version and outputs the toggling frequencies in Hz at the end. The controllers are classified by

  1. Open loop
    • Direct GPIO
    • Function Gpio->Value
  2. Closed loop
    • Input direct GPIO, output direct GPIO
    • Input function Gpio->Value, output direct GPIO
    • Input function Gpio->Value, output function Gpio->setValue
    • Input Adc->Value, output direct GPIO
    • Input Adc->Value, output function Gpio->Value

Licence: GPLv3, Copyright 2017-2023 by Thomas{ doT ]Freiherr[ At ]gmx[ DoT }net

Run by: python performance.py

Since
0.6.0

Definition in file performance.py.

Variable Documentation

◆ desc

list performance.desc
Initial value:
1 = [
2  "Open loop, direct GPIO"
3 , "Open loop, function Gpio->Value"
4 , "Closed loop, direct GPIO to direct GPIO"
5 , "Closed loop, function Gpio->Value to direct GPIO"
6 , "Closed loop, function Gpio->Value to function Gpio->setValue"
7 , "Closed loop, Adc->Value to direct GPIO"
8 , "Closed loop, Adc->Value to function Gpio->Value"
9 ]

Test descriptions.

Definition at line 42 of file performance.py.