On 16.04.2021 00:39, Waldek Hebisch wrote:
> On Thu, Apr 15, 2021 at 05:59:54PM +0200, Ralf Hemmecke wrote:
>> I am calling an external program in a .spad file like this:
>>
>> systemCommand(cmd)$MoreSystemCommands
>>
>> where cmd is
>>
>> "system /usr/bin/zsolve-4ti2 DATA"
>>
>> When I switch on timing I get something like and call the function from
>> my .spad file, I get
>>
>> Time: 0 (IN) + 0.04 (EV) + 0.00 (OT) = 0.05 sec
>>
>> although the actual computation (via 4ti2) took actually longer than one
>> minute.
>>
>> Understandibly, the time spent in FriCAS is negligible, but is there
>> some way to tell FriCAS to show the time spent in the external computation?
>
> ATM no. This requires support in operationg system which in turn
> would require support in Lisp.
According to
https://stackoverflow.com/questions/6065446/executing-a-shell-command-from-common-lisp,
"uiop:run-program" is a viable solution.
"Trivial shell" also works fine:
https://common-lisp.net/project/trivial-shell/,
however, requires some installations, whereas "uiop" loads with "(require :asdf)".
syscmd(s) ==> systemCommand(s)$MoreSystemCommands
lisp1(s) ==> syscmd(string(FORMAT('NIL,"lisp ~A",s)$Lisp))
Example: sleep 2 sec
lisp1 "(require :asdf)"
lisp1 "(time (uiop:run-program _"sleep 2_" :output *standard-output*))"
thus:
mysys(cmd) == lisp1(FORMAT('NIL, "(time (uiop:run-program _"~A_" _
:output *standard-output*))", cmd)$Lisp)
(11) -> mysys "sleep 4"
Compiling function mysys with type String -> Void
Evaluation took:
4.049 seconds of real time
0.000000 seconds of total run time (0.000000 user, 0.000000 system)
0.00% CPU
4 forms interpreted
12,522,875,702 processor cycles
65,504 bytes consed
> We probably could do this using
> implementation specific features, but up to now nobody implemented
> it.
>
Would it be wortwhile at all? IMO everyone can piece together a function using
the simple lisp constructions mentioned above.