[Swift-commit] r4198 - in SwiftApps/SwiftR/Swift: R tests tests/OpenMx

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Fri Mar 18 12:30:41 CDT 2011


Author: tga
Date: 2011-03-18 12:30:40 -0500 (Fri, 18 Mar 2011)
New Revision: 4198

Modified:
   SwiftApps/SwiftR/Swift/R/Apply.R
   SwiftApps/SwiftR/Swift/tests/OpenMx/BootstrapParallelBigger.R
   SwiftApps/SwiftR/Swift/tests/perf_tests.R
Log:
* Tweak to BootstrapParalel benchmark - don't build models in parallel
* Added in optional printing of time taken to serial to swiftapply


Modified: SwiftApps/SwiftR/Swift/R/Apply.R
===================================================================
--- SwiftApps/SwiftR/Swift/R/Apply.R	2011-03-18 15:29:58 UTC (rev 4197)
+++ SwiftApps/SwiftR/Swift/R/Apply.R	2011-03-18 17:30:40 UTC (rev 4198)
@@ -16,7 +16,8 @@
                         keepwork=NULL,
                         tmpdir=NULL,
                         timeout=NULL, 
-                        quiet=FALSE)
+                        quiet=NULL,
+                        printTiming=NULL)
 {
   # Set Swift default options if not passed as keywords or pre-set by user
   if(is.null(server)) server <- getOption("swift.server")
@@ -45,6 +46,9 @@
 
   if(is.null(quiet)) quiet <- getOption("swift.quiet")
   if(is.null(quiet)) quiet <- FALSE
+  
+  if(is.null(printTiming)) printTiming <- getOption("swift.printtiming")
+  if(is.null(printTiming)) printTiming <- FALSE
 
   # Inform user of some call info
   if (! quiet) {
@@ -60,10 +64,19 @@
 
   # Execute the calls in batches
   reqdir <- setupRequestDir(tmpdir=tmpdir)
+  if (printTiming) 
+      startTime = proc.time()[["elapsed"]]
   nbatches <- writeRequestBatches(func, arglists, initialexpr, 
                 reqdir, callsperbatch)
 
-  if (! quiet) cat("Swift request written to: ",reqdir,"\n")
+  if (printTiming) {
+    endTime = proc.time()[["elapsed"]]
+    cat(nbatches, "Swift request files written to: ", reqdir,
+        "in", sprintf("%.2f", endTime - startTime), "s\n")
+  }
+  else if (!quiet)  {
+    cat(nbatches, "Swift request files written to: ", reqdir, "\n")
+  }
 
   if( runmode == "manual" ) { 
     # Prompt for return (empty line) to continue; assumes user ran a 
@@ -106,8 +119,17 @@
     stop(paste("Invalid runmode", runmode))
   }
 
+ 
+  if (printTiming) startTime = proc.time()[["elapsed"]]
   # Fetch the batch results
-  return(fetchBatchResults(reqdir, nbatches, arglists, keepwork))
+  res <- fetchBatchResults(reqdir, nbatches, arglists, keepwork)
+  if (printTiming) {
+    endTime = proc.time()[["elapsed"]]
+    cat(paste("Swift results retrieved from disk in",
+        sprintf("%.2f", endTime - startTime), "s\n"))
+  }
+
+  return (res)
 }
 
 swiftLapply <- function( tlist, func, ... )

Modified: SwiftApps/SwiftR/Swift/tests/OpenMx/BootstrapParallelBigger.R
===================================================================
--- SwiftApps/SwiftR/Swift/tests/OpenMx/BootstrapParallelBigger.R	2011-03-18 15:29:58 UTC (rev 4197)
+++ SwiftApps/SwiftR/Swift/tests/OpenMx/BootstrapParallelBigger.R	2011-03-18 17:30:40 UTC (rev 4198)
@@ -35,7 +35,10 @@
 # parameters.
 bootstrapTest <- function (nVar, nObs, nReps) {
     set.seed(10)
+    startTime = proc.time()[["elapsed"]]
     topModel <- buildModels(nVar, nObs, nReps)
+    endTime = proc.time()[["elapsed"]]
+    cat(paste("Took", endTime - startTime, "s to build models\n"))
 
     modelResults <- mxRun(topModel, silent=TRUE, suppressWarnings=TRUE)
 
@@ -124,7 +127,16 @@
     # Don't need to export as local environment will automatically
     # be sent
     #swiftExportAll()
-    submodels <- omxLapply(1:nReps, createNewModel, 'stErrSim', template)
+    if (FALSE) {
+        oldSetting <- getOption("swift.callsperbatch")
+        options(swift.callsperbatch=128)
+        submodels <- omxLapply(1:nReps, createNewModel, 'stErrSim', template)
+        options(swift.callsperbatch=oldSetting)
+    }
+    else {
+        submodels <- lapply(1:nReps, createNewModel, 'stErrSim', template)
+    }
+
     cat(length(submodels), "submodels created\n")
 #    names(submodels) <- imxExtractNames(submodels)
     names(submodels) <- imxExtractNames(submodels)

Modified: SwiftApps/SwiftR/Swift/tests/perf_tests.R
===================================================================
--- SwiftApps/SwiftR/Swift/tests/perf_tests.R	2011-03-18 15:29:58 UTC (rev 4197)
+++ SwiftApps/SwiftR/Swift/tests/perf_tests.R	2011-03-18 17:30:40 UTC (rev 4198)
@@ -10,6 +10,8 @@
     }
     library(Swift)
     swiftSess <- swiftInit(...)
+    options(.swift.printtiming=getOption("swift.printtiming"))
+    options(swift.printtiming=TRUE)
     # Wait to start
     Sys.sleep(10)
     # Run some small jobs to ensure workers are started and warmed up
@@ -21,6 +23,7 @@
 
 swiftTearDown <- function (...) {
     swiftShutdown()
+    options(swift.printtiming=getOption(".swift.printtiming"))
     dt <- getOption(".swift.detach")
     options(.swift.detach=NULL)
     if (!is.null(dt) && dt) {




More information about the Swift-commit mailing list