about summary refs log tree commit diff stats
path: root/sandbox/005-sandbox.mu
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2017-06-25 13:04:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2017-06-25 13:04:04 -0700
commite3c9e1536154e0dee2c15b556a2a6b9f6524e114 (patch)
tree45afca3c6b1710188a25089717d1200d3c022932 /sandbox/005-sandbox.mu
parentdc5f112c3ea8aff1a389513fa6c33d88fab07420 (diff)
downloadmu-e3c9e1536154e0dee2c15b556a2a6b9f6524e114.tar.gz
3959
Don't unnecessarily write sandboxes to disk on F4.

This seems to save almost 20% time when processing a large lesson
directory with 36 sandboxes.
Diffstat (limited to 'sandbox/005-sandbox.mu')
-rw-r--r--sandbox/005-sandbox.mu16
1 files changed, 14 insertions, 2 deletions
diff --git a/sandbox/005-sandbox.mu b/sandbox/005-sandbox.mu
index c913e796..f2ab15ce 100644
--- a/sandbox/005-sandbox.mu
+++ b/sandbox/005-sandbox.mu
@@ -156,13 +156,14 @@ def run-sandboxes env:&:environment, resources:&:resources, screen:&:screen -> e
     sandbox-count:num <- get *env, number-of-sandboxes:offset
     sandbox-count <- add sandbox-count, 1
     *env <- put *env, number-of-sandboxes:offset, sandbox-count
+    # save all sandboxes
+    # needs to be before running them, in case we die when running
+    save-sandboxes env, resources
     # clear sandbox editor
     init:&:duplex-list:char <- push 167/§, 0/tail
     *current-sandbox <- put *current-sandbox, data:offset, init
     *current-sandbox <- put *current-sandbox, top-of-screen:offset, init
   }
-  # save all sandboxes before running, just in case we die when running
-  save-sandboxes env, resources
   # run all sandboxes
   curr:&:sandbox <- get *env, sandbox:offset
   idx:num <- copy 0
@@ -210,6 +211,7 @@ def update-status screen:&:screen, msg:text, color:num -> screen:&:screen [
 def save-sandboxes env:&:environment, resources:&:resources -> resources:&:resources [
   local-scope
   load-ingredients
+  trace 11, [app], [save sandboxes]
   current-sandbox:&:editor <- get *env, current-sandbox:offset
   # first clear previous versions, in case we deleted some sandbox
   $system [rm lesson/[0-9]* >/dev/null 2>/dev/null]  # some shells can't handle '>&'
@@ -570,6 +572,7 @@ scenario run-updates-results [
   # sandbox editor contains an instruction without storing outputs
   env:&:environment <- new-programming-environment resources, screen, [foo]  # contents of sandbox editor
   render-all screen, env, render
+  $clear-trace
   # run the code in the editors
   assume-console [
     press F4
@@ -585,6 +588,10 @@ scenario run-updates-results [
     .──────────────────────────────────────────────────.
     .                                                  .
   ]
+  # the new sandbox should be saved to disk
+  trace-should-contain [
+    app: save sandboxes
+  ]
   # make a change (incrementing one of the args to 'add'), then rerun
   assume-resources [
     [lesson/recipes.mu] <- [
@@ -596,6 +603,7 @@ scenario run-updates-results [
       |]|
     ]
   ]
+  $clear-trace
   assume-console [
     press F4
   ]
@@ -613,6 +621,10 @@ scenario run-updates-results [
     .──────────────────────────────────────────────────.
     .                                                  .
   ]
+  # no need to save sandboxes all over again
+  trace-should-not-contain [
+    app: save sandboxes
+  ]
 ]
 
 scenario run-instruction-manages-screen-per-sandbox [