Skip to content

Commit

Permalink
Add scripts for rough benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitk-singh committed Aug 29, 2016
1 parent 4228e50 commit defecde
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
44 changes: 44 additions & 0 deletions host/benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#! /usr/bin/python

import sys, os
import time
import random

from pylibftdi import Driver, Device

dev_list = Driver().list_devices()
if len(dev_list) != 0:
print "Following devices found:"
for device_ in dev_list:
print device_

dev = Device(device_id="FTZ17IRO", mode='b', interface_select=2)
dev.open()


epochs = 1024*10
BLOCK_LEN = 2048
tx_data = bytearray([ random.randrange(0, 256) for i in range(BLOCK_LEN)])
ts = time.time()
while epochs:

dev.write(tx_data)
rx_data = bytearray(dev.read(BLOCK_LEN))

#print "Epoch: {}".format(epochs)
failed = False
for i in range(BLOCK_LEN):
if ((tx_data[i]+1)%256) != rx_data[i]:
print "Epoch: {}".format(epochs)
print "[Test] Test 2: Data verification failed! , tx_data : ", tx_data[i], " =/= rx_data : ", rx_data[i]
failed = True
print "Breaking..."
break
if failed:
break

epochs -= 1

dev.close()
te = time.time()
print "Time {}".format(str(te-ts))
15 changes: 15 additions & 0 deletions host/run_benchmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import sys
import subprocess

times = []
epochs = 10

while epochs:
run = subprocess.Popen(["python", "benchmark.py"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for line in run.stdout:
if "Time" in line:
times.append(float(line.split()[1]))

print times

2 changes: 1 addition & 1 deletion host/test_saturn_ft2232.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
tx_data = bytearray(range(0, 256))
dev.write(tx_data)

rx_data = bytearray(dev.read(257, timeout = 0))
rx_data = bytearray(dev.read(257))#, timeout = 0))

if len(rx_data) == 256 :
print "\n\n[Test] Test 1 Passed: Sent 256 bytes of data, received 256 bytes of data"
Expand Down

0 comments on commit defecde

Please sign in to comment.