Reduce startup time for script processing?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Reduce startup time for script processing?

Andreas Weber-6
Dear all,

I'm using GNU Octave 3.8.2 on an embedded system (RPi3) to execute
scripts and print the results multiple times.

foo.m:
printf ("bar\n")

$ octave -f --no-gui foo.m

This takes 1,3s on my system. Is there anything I can do to reduce the
"startup" time? Preload Octave into RAM? It would be okay if the first
start is slow and the subsequent runs are fast.

Thank you, Andy


Reply | Threaded
Open this post in threaded view
|

Re: Reduce startup time for script processing?

Carlo de Falco-2


> Il giorno 04 lug 2019, alle ore 09:26, Andreas Weber <[hidden email]> ha scritto:
>
> Dear all,
>
> I'm using GNU Octave 3.8.2 on an embedded system (RPi3) to execute
> scripts and print the results multiple times.
>
> foo.m:
> printf ("bar\n")
>
> $ octave -f --no-gui foo.m
>
> This takes 1,3s on my system. Is there anything I can do to reduce the
> "startup" time? Preload Octave into RAM? It would be okay if the first
> start is slow and the subsequent runs are fast.
>
> Thank you, Andy


This is just a guess, I'm not actually sure it would be any better, but you could maybe try keep octave running and communicate via a named pipe?


foo.m:

#!/path/to/octave-cli -fq

fname = argv{1};
while true
  fid = fopen (fname, "r");
  a = fgetl (fid);
  if (a != -1)
    disp (a)
  endif
  fclose (fid);
  pause (.1)
endwhile

$ chmod u+x ./foo.m &
$ ./foo.m tmpfile
$ echo bar >> tmpfile
$ echo bar >> tmpfile

HTH,
c.







Reply | Threaded
Open this post in threaded view
|

Re: Reduce startup time for script processing?

Carlo de Falco-2


> Il giorno 04 lug 2019, alle ore 11:14, Carlo De Falco <[hidden email]> ha scritto:
>
>
>
>> Il giorno 04 lug 2019, alle ore 09:26, Andreas Weber <[hidden email]> ha scritto:
>>
>> Dear all,
>>
>> I'm using GNU Octave 3.8.2 on an embedded system (RPi3) to execute
>> scripts and print the results multiple times.
>>
>> foo.m:
>> printf ("bar\n")
>>
>> $ octave -f --no-gui foo.m
>>
>> This takes 1,3s on my system. Is there anything I can do to reduce the
>> "startup" time? Preload Octave into RAM? It would be okay if the first
>> start is slow and the subsequent runs are fast.
>>
>> Thank you, Andy
>
>
> This is just a guess, I'm not actually sure it would be any better, but you could maybe try keep octave running and communicate via a named pipe?

oops, you also need to create the named pipe!

>
> foo.m:
>
> #!/path/to/octave-cli -fq
>
> fname = argv{1};
> while true
>  fid = fopen (fname, "r");
>  a = fgetl (fid);
>  if (a != -1)
>    disp (a)
>  endif
>  fclose (fid);
>  pause (.1)
> endwhile
>
$ mkfifo -m a+rw tmpfile
>
> $ chmod u+x ./foo.m &
> $ ./foo.m tmpfile
> $ echo bar >> tmpfile
> $ echo bar >> tmpfile
>
> HTH,
> c.





Reply | Threaded
Open this post in threaded view
|

Re: Reduce startup time for script processing?

Carlo de Falco-2


> Il giorno 04 lug 2019, alle ore 11:22, Carlo de Falco <[hidden email]> ha scritto:
>
>
>
>> Il giorno 04 lug 2019, alle ore 11:14, Carlo De Falco <[hidden email]> ha scritto:
>>
>>
>>
>>> Il giorno 04 lug 2019, alle ore 09:26, Andreas Weber <[hidden email]> ha scritto:
>>>
>>> Dear all,
>>>
>>> I'm using GNU Octave 3.8.2 on an embedded system (RPi3) to execute
>>> scripts and print the results multiple times.
>>>
>>> foo.m:
>>> printf ("bar\n")
>>>
>>> $ octave -f --no-gui foo.m
>>>
>>> This takes 1,3s on my system. Is there anything I can do to reduce the
>>> "startup" time? Preload Octave into RAM? It would be okay if the first
>>> start is slow and the subsequent runs are fast.
>>>
>>> Thank you, Andy
>>
>>
>> This is just a guess, I'm not actually sure it would be any better, but you could maybe try keep octave running and communicate via a named pipe?

here's a more clean example, sorry.

foo.m:

#!/path/to/octave-cli -fq

fname = argv{1};
while true
fid = fopen (fname, "r");
a = fgetl (fid);
if (a != -1)
  disp (a)
endif
fclose (fid);
pause (.1)
endwhile

$ mkfifo -m a+rw tmpfile
$ chmod u+x ./foo.m
$ ./foo.m tmpfile &
$ echo bar >> tmpfile
$ echo bar >> tmpfile

c.