I have written a Mathematica script that is to be run periodically on a Raspberry Pi. The code takes about 3 seconds to execute if I test it in a CLI Mathematica session. However, when I execute the script with
wolfram -script script.w > out.csv
it takes more than 10 seconds. The output of the script is a single String
three ASCII characters long, so writing output to file does not take a significat part of the time. I thus assume most of the extra time comes from kernel initialization.
I'd like to initialize Mathematica kernel once and then run my script periodically without needing to initialize the kernel every time. Is this possible?
UPDATE
Following the answer from this related question I tried to make it work like this:
mkfifo mmpipe
tail -f mmpipe | wolfram -noprompt &
However, when I pipe a command that contains a file-importing function like ReadList, it stays in interactive mode and does not exit to shell:
echo 'ReadList["/home/pi2/data.csv","String"]'>mmpipe
{ ... , "2014/02/05 21:35:02,0.28", "2014/02/05 21:40:02,0.00", "2014/02/05 21:50:02,0.00"}
_
So I can't use it in an automated process.
Comments
Post a Comment