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

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Sat Sep 14 08:17:58 EDT 2013


Author: marcus
Date: Sat Sep 14 08:17:57 2013
New Revision: 15782

Log:
Use the update option also for the memory scripts.

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

Modified: mlpack/conf/jenkins-conf/benchmark/Makefile
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/Makefile	(original)
+++ mlpack/conf/jenkins-conf/benchmark/Makefile	Sat Sep 14 08:17:57 2013
@@ -94,7 +94,7 @@
 	$(PYTHON_BIN) $(BENCHMARKDDIR)/run_benchmark.py -c $(CONFIG) -b $(BLOCK) -l $(LOG) -u $(UPDATE) -m $(METHODBLOCK)
 
 .memory:
-	$(PYTHON_BIN) $(BENCHMARKDDIR)/memory_benchmark.py -c $(CONFIG) -b $(BLOCK) -l $(LOG)
+	$(PYTHON_BIN) $(BENCHMARKDDIR)/memory_benchmark.py -c $(CONFIG) -b $(BLOCK) -l $(LOG) -u $(UPDATE) -m $(METHODBLOCK)
 
 .reports:
 	$(PYTHON_BIN) $(BENCHMARKDDIR)/make_reports.py -c $(CONFIG)

Modified: mlpack/conf/jenkins-conf/benchmark/benchmark/memory_benchmark.py
==============================================================================
--- mlpack/conf/jenkins-conf/benchmark/benchmark/memory_benchmark.py	(original)
+++ mlpack/conf/jenkins-conf/benchmark/benchmark/memory_benchmark.py	Sat Sep 14 08:17:57 2013
@@ -72,8 +72,10 @@
 @param configfile - Create the reports with the given configuration file.
 @param blocks - Run only the specified blocks.
 @param log - If True save the reports otherwise use stdout and print the reports.
+ at param methodBlocks - Run only the specified methods.
+ at param update - Update the memory records in the database.
 '''
-def Main(configfile, blocks, log):
+def Main(configfile, blocks, log, methodBlocks, update):
   # Benchmark settings.
   timeout = 23000
   database = "reports/benchmark.db"
@@ -109,77 +111,92 @@
   for method, sets in streamData.items():
     if method == "general":
       continue
-    Log.Info("Method: " + method)    
-    for options, libraries in sets.items():
-      Log.Info('Options: ' + (options if options != '' else 'None'))
-
-      if log:
-        methodId = db.GetMethod(method, options)
-        methodId = methodId[0][0] if methodId else db.NewMethod(method, options)
-
-      for libary in libraries:
-        name = libary[0]
-        datsets = libary[1]
-        script = libary[3]
-        format = libary[4]
-        
-        if not blocks or name in blocks:
-          Log.Info("Libary: " + name)
-
-          # Logging: create a new library record for this library.
-          if log and name not in build:
-            libaryId = db.GetLibrary(name + "_memory")
-            libaryId = libaryId[0][0] if libaryId else db.NewLibrary(name + "_memory")
-
-            build[name] = (db.NewBuild(libaryId), libaryId)
-
-          # Load the script.
-          try:
-            module = Loader.ImportModuleFromPath(script)
-            methodCall = getattr(module, method)
-          except Exception as e:
-            Log.Fatal("Could not load the script: " + script)
-            Log.Fatal("Exception: " + str(e))
-          else:
-
-            for dataset in datsets:
-              datasetName = NormalizeDatasetName(dataset)
-
-              # Logging: Create a new dataset record fot this dataset.
-              if log:
-                datasetId = db.GetDataset(datasetName)
-                datasetId = datasetId[0][0] if datasetId else db.NewDataset(*DatasetInfo(dataset))
-
-              Log.Info("Dataset: " + datasetName)
-              modifiedDataset = GetDataset(dataset, format)
-
-              try:
-                instance = methodCall(modifiedDataset[0], timeout=timeout, 
-                  verbose=False)
-              except Exception as e:
-                Log.Fatal("Could not call the constructor: " + script)
-                Log.Fatal("Exception: " + str(e))
-                continue
-
-              # Generate a "unique" name for the memory output file.
-              outputName = "reports/etc/" + str(hash(datetime.datetime.now())) + ".mout"
-
-              try:
-                err = instance.RunMemoryProfiling(options, outputName);
-              except Exception as e:
-                Log.Fatal("Exception: " + str(e))
-                
+    if not methodBlocks or method in methodBlocks:
+      Log.Info("Method: " + method)
+      for options, libraries in sets.items():
+        Log.Info('Options: ' + (options if options != '' else 'None'))
+
+        if log:
+          methodId = db.GetMethod(method, options)
+          methodId = methodId[0][0] if methodId else db.NewMethod(method, options)
+
+        for libary in libraries:
+          name = libary[0]
+          datsets = libary[1]
+          script = libary[3]
+          format = libary[4]
+          
+          if not blocks or name in blocks:
+            Log.Info("Libary: " + name)
+
+            # Logging: create a new library record for this library.
+            if log and name not in build:
+              libaryId = db.GetLibrary(name + "_memory")
+              libaryId = libaryId[0][0] if libaryId else db.NewLibrary(name + "_memory")
+
+              if update:
+                buildId = db.GetLatestBuildFromLibary(libaryId)
+                if buildId >= 0:
+                  build[name] = (buildId, libaryId)
+                else:
+                  Log.Warn("Nothing to update.")
+                  continue
+              else:
+                build[name] = (db.NewBuild(libaryId), libaryId)
+
+            # Load the script.
+            try:
+              module = Loader.ImportModuleFromPath(script)
+              methodCall = getattr(module, method)
+            except Exception as e:
+              Log.Fatal("Could not load the script: " + script)
+              Log.Fatal("Exception: " + str(e))
+            else:
+
+              for dataset in datsets:
+                datasetName = NormalizeDatasetName(dataset)
+
+                # Logging: Create a new dataset record fot this dataset.
+                if log:
+                  datasetId = db.GetDataset(datasetName)
+                  datasetId = datasetId[0][0] if datasetId else db.NewDataset(*DatasetInfo(dataset))
+
+                Log.Info("Dataset: " + datasetName)
+                modifiedDataset = GetDataset(dataset, format)
+
+                try:
+                  instance = methodCall(modifiedDataset[0], timeout=timeout, 
+                    verbose=False)
+                except Exception as e:
+                  Log.Fatal("Could not call the constructor: " + script)
+                  Log.Fatal("Exception: " + str(e))
+                  continue
+
+                # Generate a "unique" name for the memory output file.
+                outputName = "reports/etc/" + str(hash(datetime.datetime.now())) + ".mout"
+
+                try:
+                  err = instance.RunMemoryProfiling(options, outputName);
+                except Exception as e:
+                  Log.Fatal("Exception: " + str(e))
+                  
+                  # Remove temporary datasets.
+                  RemoveDataset(modifiedDataset[1])
+                  continue
+
+                # Save results in the database if the user asked for.
+                if err != -1 and log:
+                  buildId, libaryId = build[name]
+
+                  if update:
+                    db.UpdateMemory(buildId, libaryId, methodId, datasetId, 
+                        outputName)
+                  else:
+                    db.NewMemory(buildId, libaryId, methodId, datasetId, 
+                        outputName)
+
                 # Remove temporary datasets.
                 RemoveDataset(modifiedDataset[1])
-                continue
-
-              # Save results in the database if the user asked for.
-              if err != -1 and log:
-                buildId, libaryId = build[name]
-                db.NewMemory(buildId, libaryId, methodId, datasetId, outputName)
-
-              # Remove temporary datasets.
-              RemoveDataset(modifiedDataset[1])
 
 if __name__ == '__main__':
   parser = argparse.ArgumentParser(description="""Perform the benchmark with the
@@ -190,9 +207,14 @@
       required=False)
   parser.add_argument('-l','--log', help='Save the results in the logfile.', 
       required=False)
+  parser.add_argument('-u','--update', help="""Update the results in the 
+      database.""", required=False)
+  parser.add_argument('-m','--methodBlocks', help="""Run only the specified 
+      method blocks.""", required=False)
 
   args = parser.parse_args()
 
   if args:
     log = True if args.log == "True" else False
-    Main(args.config, args.blocks, log)
+    update = True if args.update == "True" else False
+    Main(args.config, args.blocks, log, args.methodBlocks, update)

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	Sat Sep 14 08:17:57 2013
@@ -370,7 +370,7 @@
   Add a new memory record to the memory table.
 
   @param buildId - The build id.
-  @param libaryId - The id ot the library.
+  @param libaryId - The id of the library.
   @param methodId - The id of the method
   @param datasetId - The id of the dataset.
   @param memoryInfo - The text for the memory value.
@@ -381,6 +381,22 @@
           (buildId, libaryId, methodId, datasetId, memoryInfo))
 
   '''
+  Update the given memory record in the memory table.
+
+  @param buildId - The build id.
+  @param libaryId - The id of the library.
+  @param methodId - The id of the method
+  @param datasetId - The id of the dataset.
+  @param memoryInfo - The text for the memory value.
+  '''
+  def UpdateMemory(self, buildId, libaryId, methodId, datasetId, memoryInfo):
+     with self.con:
+      self.cur.execute("UPDATE memory SET memory_info=\'" + memoryInfo
+        + "\' WHERE build_id=" + str(buildId) + " AND libary_id=" 
+        + str(libaryId) + " AND dataset_id=" + str(datasetId) 
+        + " AND method_id=" + str(methodId))
+
+  '''
   Get the memory informations of the given parameters.
 
   @param buildId - The id of the build.



More information about the mlpack-svn mailing list