Thank you to Richard and Volker !
"apply(time, labels);" is MUCH better than my previous try.
But I still cannot have it done completely automatically, since I need
to hit one "return" key (or "end of instruction") for each
time-measurable output. I would like to put everything inside a loop
giving many time-measurable outputs : if the complexity of f(n) depends
non smoothly on n, I need to test MANY values of n. I don't want to hit
that many return keys. I might construct a string
"f(1);f(2);f(3);...;f(30);" but how to execute it ?
One way I see for doing this is almost ok, although not very natural :
to get all the times for f(1),...,f(30), I construct via a loop a file
containing a sequence of 30 maxima instructions, then batch it to get
all outputs, and finally apply time to get all times, like this :
f(i):=i^2;
with_stdout("tmp.out", print("outchar:TT$"),
for i thru 30 do print("f(",i,");"),
print("outchar:%o;"));
batch("tmp.out");
apply(time,labels(TT));
I said ALMOST ok, because I am not able to put this into a working test
FUNCTION : the "batch" instruction inside a function never terminates,
hence the apply(time...) is not done. Maybe the file to batch should end
with some blank line ?
Here is what I tried :
test(n):=(
with_stdout("tmp.out", print("outchar:TT$"),
for i thru n do print("f(",i,");"),
print("outchar:%o;")),
batch("tmp.out"),
apply(time,labels(TT)));
test(10);
Everything is executed until end of batch which does'nt continue with
next instruction.
But this is only a "batch" question that might be better discussed under
another thread ? Related : is it possible to batch two or more files
automatically ? Is it allowed to batch a file containing another batch
instruction ? Recursively ?
Returning to my time problem, I imagine another more natural solution,
avoiding external "output file", would be to drive a clock. Since the
"time" function can measure times for outputs, there should be somewhere
inside maxima (or lisp ?) an instruction telling to start a clock and
somewhere else another asking for stopping it and putting the time
difference in some place ; which instructions ? which place ? Is it a
complicated program or a one line instruction easy to imitate ?
Thank you for any ideas.
Eric
Richard Fateman a ?crit :
> Try describe(time) for info. All the times can be printed out in a list,
> if you use, say, apply(time, labels);
>
> RJF
> -----Original Message-----
>> .....
>> I would like to compare the time complexities of some functions that I
>> defined with Maxima. Is there a better way to collect the times than
>>
>> showtime:true;
>> f(1); f(2); ...
>> f(2^30);
>>
>> and then copy-paste-clean "by hand" Maxima's results ?
>> ....
>
>