[mlpack-svn] r15595 - in mlpack/conf/jenkins-conf/benchmark: benchmark util

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Aug 7 14:32:33 EDT 2013


Author: marcus
Date: Wed Aug  7 14:32:33 2013
New Revision: 15595

Log:
Add a library id to the builds table and function to get the summed time values.

Modified:
   mlpack/conf/jenkins-conf/benchmark/benchmark/run_benchmark.py
   mlpack/conf/jenkins-conf/benchmark/util/database.py

Modified: mlpack/conf/jenkins-conf/benchmark/benchmark/run_benchmark.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/benchmark/run_benchmark.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/benchmark/run_benchmark.py	Wed Aug  7 14:32:33 2013
@@ -196,7 +196,7 @@
           libaryId = db.GetLibrary(name)
           libaryId = libaryId[0][0] if libaryId else db.NewLibrary(name)
 
-          build[name] = (db.NewBuild(), libaryId)
+          build[name] = (db.NewBuild(libaryId), libaryId)
         
         if not blocks or name in blocks:
           run += 1

Modified: mlpack/conf/jenkins-conf/benchmark/util/database.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/util/database.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/util/database.py	Wed Aug  7 14:32:33 2013
@@ -33,7 +33,10 @@
     self.con.executescript("""
         CREATE TABLE IF NOT EXISTS builds (
           id INTEGER PRIMARY KEY AUTOINCREMENT,
-          build TIMESTAMP NOT NULL
+          build TIMESTAMP NOT NULL,
+          libary_id INTEGER NOT NULL,
+
+          FOREIGN KEY(libary_id) REFERENCES builds(id) ON DELETE CASCADE
         );
         """)
 
@@ -100,8 +103,8 @@
   Create a new build, libraries, datasets and results table.
   '''
   def CreateTables(self):
-    self.CreateBuildTable()
     self.CreateLibrariesTable()
+    self.CreateBuildTable()
     self.CreateDatasetsTable()
     self.CreateMethodsTable()
     self.CreateResultsTable()
@@ -109,10 +112,10 @@
   '''
   Add a new build record to the builds table.
   '''
-  def NewBuild(self):
+  def NewBuild(self, libaryId):
     with self.con:
-      self.cur.execute("INSERT INTO builds VALUES(NULL, '" + 
-          str(datetime.datetime.now()) + "')")
+      self.cur.execute("INSERT INTO builds VALUES (NULL,?, ?)", 
+          (datetime.datetime.now(), libaryId))
       self.cur.execute("SELECT last_insert_rowid()")
       return self.cur.fetchall()[0][0]
 
@@ -218,3 +221,20 @@
           (name,parameters))
       self.cur.execute("SELECT last_insert_rowid()")
       return self.cur.fetchall()[0][0]
+
+  '''
+  Get the sum of the time column of all build of the given name.
+
+  @param name - The name of the library.
+  @return The sum of the time column.
+  '''
+  def GetResultsSum(self, name):
+    libaryId = self.GetLibrary(name)[0][0]
+    with self.con:
+      self.cur.execute("SELECT id FROM builds WHERE libary_id=" + str(libaryId) + " ORDER BY build ASC")
+      timeSummed = []
+      for buildId in self.cur.fetchall(): 
+        self.cur.execute("SELECT SUM(time) FROM results WHERE build_id=" + 
+           str(buildId[0]))
+        timeSummed.append(self.cur.fetchall()[0][0])
+    return timeSummed



More information about the mlpack-svn mailing list