In the last section of Pratical Common Lisp, there are some
functions¯os to test the Run-Time of any Form. Here is the most
important macro used to extent Users' Function and add its Time-
Consuming Information in *timing-data*
(defmacro with-timing (label &body body)
(with-gensyms (start)
`(let ((,start (get-internal-run-time)))
(unwind-protect (progn ,@body)
(push (list ',label ,start (get-internal-run-time))
*timing-data*)))))
e.g.
>(with-timing Sleep (sleep 1))
NIL
>*timing-data*
((Sleep 96939392 96939392))
Here, 'start' saves the time befor 'BODY' , the second 'get-internal-
run-time' saves the time after 'BODY'. However, I can never get this
'reasonable' result. In fact it returns the same number( i guess the
number is CPU di-da). Why? Does 'let' do not give 'start' any value
until 'start' exist in the program?
Thanks!
From: Espen Vestre
Subject: Re: Problem about 'get-internal-run-time'
Date:
Message-ID: <m1abrteewd.fsf@vestre.net>
··········@gmail.com" <·········@gmail.com> writes:
> Here, 'start' saves the time befor 'BODY' , the second 'get-internal-
> run-time' saves the time after 'BODY'. However, I can never get this
> 'reasonable' result. In fact it returns the same number( i guess the
> number is CPU di-da). Why? Does 'let' do not give 'start' any value
> until 'start' exist in the program?
get-internal-run-time returns the actual cpu time consumed. Presumably,
the sleep doesn't consume any measurable cpu time?
--
(espen)
From: Ken Tilton
Subject: Re: Problem about 'get-internal-run-time'
Date:
Message-ID: <iRuFi.7$Z%7.6@newsfe12.lga>
Espen Vestre wrote:
> ··········@gmail.com" <·········@gmail.com> writes:
>
>
>>Here, 'start' saves the time befor 'BODY' , the second 'get-internal-
>>run-time' saves the time after 'BODY'. However, I can never get this
>>'reasonable' result. In fact it returns the same number( i guess the
>>number is CPU di-da). Why? Does 'let' do not give 'start' any value
>>until 'start' exist in the program?
>
>
> get-internal-run-time returns the actual cpu time consumed. Presumably,
> the sleep doesn't consume any measurable cpu time?
That is what I thought until I saw the CPU pegged during a sleep. :(
Possibly this varies from Lisp to Lisp or OS to OS? I toss and turn a
lot in my sleep, so I can sympathize.
kt
--
http://www.theoryyalgebra.com/
"We are what we pretend to be." -Kurt Vonnegut
From: Espen Vestre
Subject: Re: Problem about 'get-internal-run-time'
Date:
Message-ID: <m11wd5e8ru.fsf@vestre.net>
Ken Tilton <···········@optonline.net> writes:
>> get-internal-run-time returns the actual cpu time consumed. Presumably,
>> the sleep doesn't consume any measurable cpu time?
>
> That is what I thought until I saw the CPU pegged during a sleep. :(
> Possibly this varies from Lisp to Lisp or OS to OS? I toss and turn a
> lot in my sleep, so I can sympathize.
Hehe. But /his/ implementation (whatever it is) seems to have a very
cpu-friendly implementation of sleep. Or a very coarse cpu time
counter.
--
(espen)
In article <·············@newsfe12.lga>,
Ken Tilton <···········@optonline.net> wrote:
> Espen Vestre wrote:
> > ··········@gmail.com" <·········@gmail.com> writes:
> >
> >
> >>Here, 'start' saves the time befor 'BODY' , the second 'get-internal-
> >>run-time' saves the time after 'BODY'. However, I can never get this
> >>'reasonable' result. In fact it returns the same number( i guess the
> >>number is CPU di-da). Why? Does 'let' do not give 'start' any value
> >>until 'start' exist in the program?
> >
> >
> > get-internal-run-time returns the actual cpu time consumed. Presumably,
> > the sleep doesn't consume any measurable cpu time?
>
> That is what I thought until I saw the CPU pegged during a sleep. :(
> Possibly this varies from Lisp to Lisp or OS to OS? I toss and turn a
> lot in my sleep, so I can sympathize.
Any Lisp intended for a multi-processing system that consumes CPU time
during SLEEP should be tossed out as a toy implementation. These
operating systems all have system calls that will suspend a process for
a period of time, and this is what SLEEP should use. If the Lisp
supports multi-threading there are some complications, but they're
generally easily solved and most professional implementations have done
so.
--
Barry Margolin, ······@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
On Sep 11, 5:21 pm, Espen Vestre <·····@vestre.net> wrote:
> ··········@gmail.com" <·········@gmail.com> writes:
> > Here, 'start' saves the time befor 'BODY' , the second 'get-internal-
> > run-time' saves the time after 'BODY'. However, I can never get this
> > 'reasonable' result. In fact it returns the same number( i guess the
> > number is CPU di-da). Why? Does 'let' do not give 'start' any value
> > until 'start' exist in the program?
>
> get-internal-run-time returns the actual cpu time consumed. Presumably,
> the sleep doesn't consume any measurable cpu time?
> --
> (espen)
Really? I thought that Sleep also consumes cpu time and
get-internal-run-time returns the Lisp program's whole running time no
matter
it is suspended or blocked.
of course, i am not very sure now. :)
From: Espen Vestre
Subject: Re: Problem about 'get-internal-run-time'
Date:
Message-ID: <m1wsuxctxp.fsf@vestre.net>
··········@gmail.com" <·········@gmail.com> writes:
> Really? I thought that Sleep also consumes cpu time and
> get-internal-run-time returns the Lisp program's whole running time no
> matter
> it is suspended or blocked.
> of course, i am not very sure now. :)
I think you confuse get-internal-run-time with get-internal-real-time!
Taken from the mostly idle LW on my mac laptop:
CL-USER 17 > (get-internal-run-time)
628221
CL-USER 18 > (get-internal-real-time)
365834147
CL-USER 19 > internal-time-units-per-second
1000
I.e. the get-internal-real-time value is roughly 4 days and 6 hours,
which is the elapsed time since the image was launched,
whereas the get-internal-run-time value is about 10 minutes. Both
these values are consistent with what ps tells me:
ev 343 0.8 -1.4 403636 28732 ?? S Fri07AM 10:31.16 /Applications/LispWorks 5.0/LispWorks 5.0.1.app/Contents/MacOS
--
(espen)
On Sep 11, 7:39 pm, Espen Vestre <·····@vestre.net> wrote:
> ··········@gmail.com" <·········@gmail.com> writes:
> > Really? I thought that Sleep also consumes cpu time and
> > get-internal-run-time returns the Lisp program's whole running time no
> > matter
> > it is suspended or blocked.
> > of course, i am not very sure now. :)
>
> I think you confuse get-internal-run-time with get-internal-real-time!
>
> Taken from the mostly idle LW on my mac laptop:
>
> CL-USER 17 > (get-internal-run-time)
> 628221
>
> CL-USER 18 > (get-internal-real-time)
> 365834147
>
> CL-USER 19 > internal-time-units-per-second
> 1000
>
> I.e. the get-internal-real-time value is roughly 4 days and 6 hours,
> which is the elapsed time since the image was launched,
> whereas the get-internal-run-time value is about 10 minutes. Both
> these values are consistent with what ps tells me:
>
> ev 343 0.8 -1.4 403636 28732 ?? S Fri07AM 10:31.16 /Applications/LispWorks 5.0/LispWorks 5.0.1.app/Contents/MacOS
> --
> (espen)
Thanks. Sleep does not have effect on get-internal-run-time, but
change get-internal-real-time.