polling-frequency of I/O-port

hello to every one,here is Yangyang.I want to know,how can test the polling-frequency of I/O-port on beaglebone black,and what is the maximum speed of the frequency ? The max. speed what I test is around 27kHz. Hope there is anyone can help me
contact via ahfycyy@gmail.com. Thanks.

Here is my code(python):

from bbio import *
import time

testIO = GPIO1_28 #P9_12
testVar = 0

counter = 0
cntMax = 10000
startTiME = time.time()
endTiME = 0

pinMode(testIO, INPUT)

while 1:
if counter >= cntMax:
endTiME = time.time()
print ‘Frequenz an test IO:’, cntMax / (endTiME - startTiME)
counter = 0
startTiME = time.time()
else:
if not digitalRead(testIO) == testVar:
testVar = not testVar
counter += 1

A few things about your code.

First, if you’re concerned about performance, you’re using the wrong language. Wrong type of a language for that matter. You should be using C, C++, or ASM. IF you’re concerned about performance.

Secondly, calling a time() related function in your main loop, every iteration will slow your code down.

Thirdly printing to stdout every iteration of your loop will slow your application down A LOT.

Lastly, I’m not sure if the bbio library uses sysfs for manipulating pins or not. But if it does. There are performance limitations associated with this as well.