Mastering E-Prime: Speeding computations with Suspend/Resume

David McFarlane mcfarla9 at msu.edu
Tue Mar 13 20:09:07 UTC 2012


WARNING:  The following describes advanced 
techniques.  DO NOT USE these techniques unless 
you fancy yourself a dedicated hacker.


Over at 
http://support.pstnet.com/forum/Topic5636-23-1.aspx 
there was a discussion of computational speed in 
E-Prime programs.  As discussed in that thread, 
by default, between each line of E-Basic code EP 
performs internal operations such as device 
handling.  This strategy accounts for E-Prime's 
success in handling subject inputs with 
millisecond precision, but it also significantly 
slows computations during intervals that do not 
require high-precision input.  For most of our 
projects this presents no problem, but this 
behavior does interfere with other projects 
(e.g., random movement of 500 dots).

As it turns out, EP includes facilities to 
improve computational speed during intervals when 
a task does not take input, namely 
Rte.DeviceManager.Suspend/Resume and 
Device.Suspend/Resume.  You may consult those 
topics in the E-Basic Help facility, and download 
a crude example program that I posted to the thread linked above.

For example, on one run of my test platform, 
20,000 empty loops took 5420 ms (271 µs/loop) 
normally, but only 996 ms (50 µs/loop) after 
Rte.DeviceManager.Suspend.  In sum, here are my 
cursory results from only one test platform:

- Rte.DeviceManager.Suspend
     - Speeds loop execution by a factor of roughly 5-10.
     - Makes the Display go blank.
     - No longer handles GetUserBreakState (simply ignored).
     - No longer handles the user abort sequence (user abort may actually
       crash the run).
- Suspending *all* Devices using each one's .Suspend method
     - Speeds loop execution by a factor of roughly 10-15.
     - Makes the Display go blank (as a result of Display.Suspend).
     - Still handles GetUserBreakState.
     - Still handles the user abort sequence.
- Suspending all Devices *except* Display, using each one's .Suspend
   method
     - Speeds loop execution by a factor of roughly 5.
     - Still shows the Display.
     - Still handles GetUserBreakState.
     - Still handles the user abort sequence.

Note that this behavior is the *inverse* of 
ordinary programming platforms.  Other platforms 
perform computations at maximum rate by default, 
but during intervals of user input programmers 
must take extra measures to handle that input 
with high temporal precision.  By contrast, 
E-Prime handles input with millisecond 
performance by default, but then during intervals 
that require rapid computations without user 
input programmers must take extra measures to 
suspend and then resume EP's regular input 
monitoring operations.  For many behavioral 
research projects, this is the best tradeoff.

As always, no single platform is best for every 
project, and we should pick the tools best suited to the project at hand.

-----
David McFarlane
E-Prime training 
online:  http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter:  @EPrimeMaster (twitter.com/EPrimeMaster

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.



More information about the Eprime mailing list