Skip to content

Commit

Permalink
Added custom support to select libraries and max number of points bef…
Browse files Browse the repository at this point in the history
…ore generating plots
  • Loading branch information
pranjal-rai committed Jul 25, 2017
1 parent f496622 commit 28d0200
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 54 deletions.
11 changes: 7 additions & 4 deletions benchmarkTool/randomTests/fastann_testRandom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ void kdtree_demo(const size_t N, double &buildTimer, double &queryTimer)

int main(int argc, char *argv[])
{
size_t plotCount = 10;
size_t maxSize = 10000;
// Randomize Seed
if(argc!=2)
if(argc!=3)
srand(time(NULL));
else
srand(atoi(argv[1]));
size_t plotCount = 10;
size_t maxSize = 10000;
{
srand(atoi(argv[2]));
maxSize = atoi(argv[1]);
}

// buildTime : time required to build the kd-tree index
// queryTime : time required to find nearest neighbor for a single point in the kd-tree
Expand Down
11 changes: 7 additions & 4 deletions benchmarkTool/randomTests/flann_testRandom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ void kdtree_demo(const size_t N, double &buildTimer, double &queryTimer)

int main(int argc, char *argv[])
{
size_t plotCount = 10;
size_t maxSize = 10000;
// Randomize Seed
if(argc!=2)
if(argc!=3)
srand(time(NULL));
else
srand(atoi(argv[1]));
size_t plotCount = 10;
size_t maxSize = 10000;
{
srand(atoi(argv[2]));
maxSize = atoi(argv[1]);
}

// buildTime : time required to build the kd-tree index
// queryTime : time required to find nearest neighbor for a single point in the kd-tree
Expand Down
11 changes: 7 additions & 4 deletions benchmarkTool/randomTests/libkdtree_testRandom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,16 @@ void kdtree_demo(const size_t N, double &buildTimer, double &queryTimer)

int main(int argc, char *argv[])
{
size_t plotCount = 10;
size_t maxSize = 10000;
// Randomize Seed
if(argc!=2)
if(argc!=3)
srand(time(NULL));
else
srand(atoi(argv[1]));
size_t plotCount = 10;
size_t maxSize = 10000;
{
srand(atoi(argv[2]));
maxSize = atoi(argv[1]);
}

// buildTime : time required to build the kd-tree index
// queryTime : time required to find nearest neighbor for a single point in the kd-tree
Expand Down
11 changes: 7 additions & 4 deletions benchmarkTool/randomTests/nanoflann_testRandom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,16 @@ void kdtree_demo(const size_t N, double &buildTimer, double &queryTimer)

int main(int argc, char *argv[])
{
size_t plotCount = 10;
size_t maxSize = 10000;
// Randomize Seed
if(argc!=2)
if(argc!=3)
srand(time(NULL));
else
srand(atoi(argv[1]));
size_t plotCount = 10;
size_t maxSize = 10000;
{
srand(atoi(argv[2]));
maxSize = atoi(argv[1]);
}

// buildTime : time required to build the kd-tree index
// queryTime : time required to find nearest neighbor for a single point in the kd-tree
Expand Down
61 changes: 43 additions & 18 deletions benchmarkTool/randomTests/randomTests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/python
import sys
import matplotlib.pyplot as plt
import subprocess

Expand All @@ -15,13 +16,12 @@ def cal(MatrixTime, col):
stdVal = stdVal**0.5
return meanVal, stdVal


def plotTime(execPath, numRepetitions, numDivisions):
def plotTime(execPath, numRepetitions, numDivisions, numPoints):
BuildTime = [[0.0 for x in range(numDivisions)] for y in range(numRepetitions)]
QueryTime = [[0.0 for x in range(numDivisions)] for y in range(numRepetitions)]
xaxis = []
for processCount in range(numRepetitions):
proc = subprocess.Popen([execPath + ' ' + str(processCount)], stdout=subprocess.PIPE, shell=True)
proc = subprocess.Popen([execPath + ' ' + str(numPoints) + ' ' + str(processCount) ], stdout=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
List = out.split()
for it, item in enumerate(List):
Expand All @@ -47,17 +47,36 @@ def plotTime(execPath, numRepetitions, numDivisions):

numRepetitions = 50
numDivisions = 10
numPoints = 10000 # default numPoints
nanoflannFlag = 0
flannFlag = 0
fastannFlag = 0
libkdtreeFlag = 0

if(len(sys.argv) == 6):
numPoints = int(sys.argv[1])
nanoflannFlag = int(sys.argv[2])
flannFlag = int(sys.argv[3])
fastannFlag = int(sys.argv[4])
libkdtreeFlag = int(sys.argv[5])

fig, ax = plt.subplots()
xaxis, nanoflannBuildTimeFinal, nanoflannBuildTimeError, nanoflannQueryTimeFinal, nanoflannQueryTimeError = plotTime('/home/pranjalr34/gsoc/nanoflann/build/bin/./nanoflann_testRandom', numRepetitions, numDivisions)
xaxis, flannBuildTimeFinal, flannBuildTimeError, flannQueryTimeFinal, flannQueryTimeError = plotTime('/home/pranjalr34/gsoc/nanoflann/build/bin/./flann_testRandom', numRepetitions, numDivisions)
#xaxis, fastannBuildTimeFinal, fastannBuildTimeError, fastannQueryTimeFinal, fastannQueryTimeError = plotTime('/home/pranjalr34/gsoc/nanoflann/build/bin/./fastann_testRandom', numRepetitions, numDivisions)
plt.plot(xaxis, nanoflannBuildTimeFinal, 'r', label='nanoflann', linewidth=3.0)
plt.errorbar(xaxis, nanoflannBuildTimeFinal, color='k', yerr=nanoflannBuildTimeError, fmt='o')
plt.plot(xaxis, flannBuildTimeFinal, 'g', label='flann', linewidth=3.0)
plt.errorbar(xaxis, flannBuildTimeFinal, color='k', yerr=flannBuildTimeError, fmt='o')
#plt.plot(xaxis, fastannBuildTimeFinal, 'b', label='fastann', linewidth=3.0)
#plt.errorbar(xaxis, fastannBuildTimeFinal, color='k', yerr=fastannBuildTimeError, fmt='o')
if(nanoflannFlag):
xaxis, nanoflannBuildTimeFinal, nanoflannBuildTimeError, nanoflannQueryTimeFinal, nanoflannQueryTimeError = plotTime('/home/pranjalr34/gsoc/nanoflann/build/bin/./nanoflann_testRandom', numRepetitions, numDivisions, numPoints)
plt.plot(xaxis, nanoflannBuildTimeFinal, 'r', label='nanoflann', linewidth=3.0)
plt.errorbar(xaxis, nanoflannBuildTimeFinal, color='k', yerr=nanoflannBuildTimeError, fmt='o')
if(flannFlag):
xaxis, flannBuildTimeFinal, flannBuildTimeError, flannQueryTimeFinal, flannQueryTimeError = plotTime('/home/pranjalr34/gsoc/nanoflann/build/bin/./flann_testRandom', numRepetitions, numDivisions, numPoints)
plt.plot(xaxis, flannBuildTimeFinal, 'g', label='flann', linewidth=3.0)
plt.errorbar(xaxis, flannBuildTimeFinal, color='k', yerr=flannBuildTimeError, fmt='o')
if(fastannFlag):
xaxis, fastannBuildTimeFinal, fastannBuildTimeError, fastannQueryTimeFinal, fastannQueryTimeError = plotTime('/home/pranjalr34/gsoc/nanoflann/build/bin/./fastann_testRandom', numRepetitions, numDivisions, numPoints)
plt.plot(xaxis, fastannBuildTimeFinal, 'b', label='fastann', linewidth=3.0)
plt.errorbar(xaxis, fastannBuildTimeFinal, color='k', yerr=fastannBuildTimeError, fmt='o')
if(libkdtreeFlag):
xaxis, libkdtreeBuildTimeFinal, libkdtreeBuildTimeError, libkdtreeQueryTimeFinal, libkdtreeQueryTimeError = plotTime('/home/pranjalr34/gsoc/nanoflann/build/bin/./libkdtree_testRandom', numRepetitions, numDivisions, numPoints)
plt.plot(xaxis, libkdtreeBuildTimeFinal, 'k', label='libkdtree', linewidth=3.0)
plt.errorbar(xaxis, libkdtreeBuildTimeFinal, color='k', yerr=libkdtreeBuildTimeError, fmt='o')

ax.grid(True)

Expand Down Expand Up @@ -92,12 +111,18 @@ def plotTime(execPath, numRepetitions, numDivisions):
plt.show()

fig, ax = plt.subplots()
plt.plot(xaxis, nanoflannQueryTimeFinal, 'r', label='nanoflann', linewidth=3.0)
plt.errorbar(xaxis, nanoflannQueryTimeFinal, color='k', yerr=nanoflannQueryTimeError, fmt='o')
plt.plot(xaxis, flannQueryTimeFinal, 'g', label='flann', linewidth=3.0)
plt.errorbar(xaxis, flannQueryTimeFinal, color='k', yerr=flannQueryTimeError, fmt='o')
#plt.plot(xaxis, fastannQueryTimeFinal, 'b', label='fastann', linewidth=3.0)
#plt.errorbar(xaxis, fastannQueryTimeFinal, color='k', yerr=fastannQueryTimeError, fmt='o')
if(nanoflannFlag):
plt.plot(xaxis, nanoflannQueryTimeFinal, 'r', label='nanoflann', linewidth=3.0)
plt.errorbar(xaxis, nanoflannQueryTimeFinal, color='k', yerr=nanoflannQueryTimeError, fmt='o')
if(flannFlag):
plt.plot(xaxis, flannQueryTimeFinal, 'g', label='flann', linewidth=3.0)
plt.errorbar(xaxis, flannQueryTimeFinal, color='k', yerr=flannQueryTimeError, fmt='o')
if(fastannFlag):
plt.plot(xaxis, fastannQueryTimeFinal, 'b', label='fastann', linewidth=3.0)
plt.errorbar(xaxis, fastannQueryTimeFinal, color='k', yerr=fastannQueryTimeError, fmt='o')
if(libkdtreeFlag):
plt.plot(xaxis, libkdtreeQueryTimeFinal, 'k', label='libkdtree', linewidth=3.0)
plt.errorbar(xaxis, libkdtreeQueryTimeFinal, color='k', yerr=libkdtreeQueryTimeError, fmt='o')

ax.grid(True)

Expand Down
75 changes: 55 additions & 20 deletions benchmarkTool/tool.py
Original file line number Diff line number Diff line change
@@ -1,45 +1,80 @@
#!/usr/bin/python
import os
import tkFont
try:
from Tkinter import *
except ImportError:
from tkinter import *
import Tkinter as tk

def realTests():
os.system('realTests/./realTests.py')
return

def randomTests():
os.system('randomTests/./randomTests.py')
def randomTests(window, numPoints, CheckVar1, CheckVar2, CheckVar3, CheckVar4):
libState = [CheckVar1.get(), CheckVar2.get(), CheckVar3.get(), CheckVar4.get()]
os.system('randomTests/./randomTests.py ' + str(numPoints.get()) + ' ' + str(libState[0]) + ' ' + str(libState[1]) + ' ' + str(libState[2]) + ' ' + str(libState[3]))
window.destroy()
return

def DarkenLabel(C):
if(C.cget('bg') == "green"):
C.config(bg = "white")
else:
C.config(bg = "green")

def getParams():
window = tk.Toplevel(root)
window.wm_title("Select Parameters")
window.resizable(width=False, height=False)

L1 = tk.Label(window, text="Max Points")
L1.grid(row=0, column=0)

numPoints = tk.StringVar(window, value='10000')
E1 = tk.Entry(window, textvariable = numPoints, bd = 5, width = 20)
E1.grid(row=0, column=1)

CheckVar1 = tk.IntVar()
CheckVar2 = tk.IntVar()
CheckVar3 = tk.IntVar()
CheckVar4 = tk.IntVar()
C1 = tk.Checkbutton(window, text = "nanoflann", variable = CheckVar1, onvalue = 1, command = lambda: DarkenLabel(C1), background='white', offvalue = 0, height=5, width = 20)
C1.grid(row=1, column=1)
C2 = tk.Checkbutton(window, text = "flann", variable = CheckVar2, onvalue = 1, command = lambda: DarkenLabel(C2), background='white', offvalue = 0, height=5, width = 20)
C2.grid(row=2, column=1)
C3 = tk.Checkbutton(window, text = "fastann", variable = CheckVar3, onvalue = 1, command = lambda: DarkenLabel(C3), background='white', offvalue = 0, height=5, width = 20)
C3.grid(row=3, column=1)
C4 = tk.Checkbutton(window, text = "libkdtree", variable = CheckVar4, onvalue = 1, command = lambda: DarkenLabel(C4), background='white', offvalue = 0, height=5, width = 20)
C4.grid(row=4, column=1)

btn = tk.Button(window, text = 'submit', command = lambda: randomTests(window, numPoints, CheckVar1, CheckVar2, CheckVar3, CheckVar4))
btn.grid(row=5, column=1, pady = 10)
return

def createButton(TextMessage, row_index, col_index):
helv36 = tkFont.Font(family='Helvetica', size=18, weight=tkFont.BOLD)
Grid.rowconfigure(frame, row_index, weight=1)
Grid.columnconfigure(frame, col_index, weight=1)
if(TextMessage == 'Random Dataset'):
btn = Button(frame, font=helv36, text =TextMessage, command = randomTests, foreground='black', background='white', activeforeground='white', activebackground='green') #create a button inside frame
if(TextMessage == 'Real Dataset'):
btn = Button(frame, font=helv36, text =TextMessage, command = realTests, foreground='black', background='white', activeforeground='white', activebackground='green') #create a button inside frame
btn.grid(row=row_index, column=col_index, sticky=N+S+E+W)
tk.Grid.rowconfigure(frame, row_index, weight=1)
tk.Grid.columnconfigure(frame, col_index, weight=1)
if(TextMessage == 'Real Test'):
btn = tk.Button(frame, font=helv36, text =TextMessage, command = realTests, foreground='black', background='white', activeforeground='white', activebackground='green') #create a button inside frame
if(TextMessage == 'Random Test'):
btn = tk.Button(frame, font=helv36, text =TextMessage, command = getParams, foreground='black', background='white', activeforeground='white', activebackground='green') #create a button inside frame
btn.grid(row=row_index, column=col_index, sticky=tk.N+tk.S+tk.E+tk.W)

if __name__ == '__main__':
#Create & Configure root
root = Tk()
col = 'white'
root = tk.Tk()
root.wm_title("Benchmarking Tool")
height = 400
width = 250
root.geometry('{}x{}'.format(height, width))
root.minsize(height, width)
root.maxsize(height*2, width*2)
Grid.rowconfigure(root, 0, weight=1)
Grid.columnconfigure(root, 0, weight=1)
tk.Grid.rowconfigure(root, 0, weight=1)
tk.Grid.columnconfigure(root, 0, weight=1)

frame=Frame(root)
frame.grid(row=0, column=0, sticky=N+S+E+W)
frame=tk.Frame(root)
frame.grid(row=0, column=0, sticky=tk.N+tk.S+tk.E+tk.W)

createButton("Real Dataset", 0, 0)
createButton("Random Dataset", 1, 0)
createButton("Real Test", 0, 0)
createButton("Random Test", 1, 0)

root.mainloop()

0 comments on commit 28d0200

Please sign in to comment.