4ti2 and )set message time on

7 views
Skip to first unread message

Ralf Hemmecke

unread,
Apr 15, 2021, 11:59:56 AM4/15/21
to fricas-devel
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?

Ralf

Waldek Hebisch

unread,
Apr 15, 2021, 6:39:49 PM4/15/21
to fricas...@googlegroups.com
ATM no. This requires support in operationg system which in turn
would require support in Lisp. We probably could do this using
implementation specific features, but up to now nobody implemented
it.

--
Waldek Hebisch

Kurt Pagani

unread,
Apr 15, 2021, 7:48:10 PM4/15/21
to fricas...@googlegroups.com
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.




Waldek Hebisch

unread,
Apr 15, 2021, 9:34:13 PM4/15/21
to fricas...@googlegroups.com
Sorry Kurt, I do not know what the command above are supposed to
solve. First, ASDF does not "always" work:

)lisp (require :asdf)

>> System error:
Don't know how to REQUIRE ASDF.
See also:
The SBCL Manual, Variable SB-EXT:*MODULE-PROVIDER-FUNCTIONS*
The SBCL Manual, Function REQUIRE

Correctly setting up ASDF requieres some effort...

We can run shell commands, Ralf asked about having their
CPU time counted to total CPU time (note that our time report
is about CPU time). Avoiding poblematic dependency I did:

)lisp (time (sb-ext::run-program "/bin/sh" '("-c" "(yes | head -c 100000000 | wc)") :search t))

Evaluation took:
3.420 seconds of real time
0.004000 seconds of total run time (0.000000 user, 0.004000 system)
0.12% CPU
20 forms interpreted
8,212,561,209 processor cycles
32,768 bytes consed

This gives right real time (we can get it without using 'time'), but
CPU time does not count external program.

--
Waldek Hebisch

Ralf Hemmecke

unread,
Apr 16, 2021, 2:48:57 AM4/16/21
to fricas...@googlegroups.com
> We can run shell commands, Ralf asked about having their
> CPU time counted to total CPU time (note that our time report
> is about CPU time).

Well, actually, I was not really requiring CPU time, but rather that the
time spent in the external program is also seen in the FriCAS timing
that is shown after every command. Note that in my case the call to the
external program happens in a library function, so a user wouldn't know
that there is an external program behind.

Well, it is not very important. I just wanted to report this "problem".

Ralf
Reply all
Reply to author
Forward
0 new messages