Andrew wrote:I'm guessing your script has lots of g_run() calls mixed up with lots of editing calls?
Exactly.
Andrew wrote:If so, put a g_new() call at the start of your script -- that will prevent lots of temporary files being created and the script will run faster. This solution assumes your script is creating a pattern rather than editing an existing pattern.
Perfect, that did the trick!
The script sets up streams ships (or any mobile pattern). I know there are a couple of similar Python scripts but I'm a Perl guy.
The script supports multiperiod streams specified by a comma-separated list, thus the need for optimization. Regular period streams are fast to generate even using a trivial implementation, but looping 10000+ times over a multiperiod stream gets slow.
Since making the original post, I tried several implementations, and a clear winner emerged from the benchmarks: get the multiperiod group into a cellarray, then loop using g_evolve to advance the entire group and g_putcells to place it in the output layer.
Here are the benchmark details (times in seconds):
Testbed: Golly 2.1 on a Core 2 Duo @1.86GHz, 32-bit Ubuntu
Test case: LWSS
Period: 100,101,100
Number: 10000
Using Quicklife:
g_evolve: 18
work layer, g_run: 324
work layer, basestep, g_step: 337
Using Hashlife:
g_evolve: 184
work layer, basestep, g_step: 400
work layer, g_run: 416
work layer, g_run, hyperspeed: 435
The obvious implementation using g_putcells and g_run in a loop is blazingly fast using HashLife for cases like single ships whose period aligns well, but becomes far too slow on multiperiod streams.
(The benchmark and implementation info is for the benefit of other new scripters.)
Thanks to Andrew, and as a result of the benchmarks, these lines were added to the start of the script:
Code: Select all
g_new("layer title");
g_setalgo("QuickLife");
Although the streaming script is working well I don't want to post it yet. The current version is interactive, but I intend to use it as part of an automated survey, so the final version will be different so as to accomodate automation.
As it's not linked with Perl, bgolly isn't suitable for my automation needs since it's not scriptable. Also, it appears to be much slower than golly.
In addition to the special golly-start.pl, a script file can be specified on the command line. This is good, and preferable in my case.
Once I finish writing the golly scripts needed to do the survey, I have some Perl tools which will automate the overall survey process. This will involve starting golly for each step. Compared to what golly will be doing each time, the overhead of restarting it will be negligible.
There are two issues when using Golly from the command line in an automated scripting environment:
- A way to cleanly shut down Golly from within a script. Using exit(0) is the workaround, so this is a minor issue.
- A command line argument to start minimized, so that it doesn't pop up in your face if you're doing something else on the machine.
At first glance it seems like a deal breaker that there's no way to tell golly to start minimized. Apparently wxWidgets applications don't have standard command line args the way X windows applications used to (e.g. -iconic). But I guess I can run the whole automated survey in a VNC session, so golly's popping up won't be an issue.