Problem about 'get-internal-run-time'

This is a discussion on Problem about 'get-internal-run-time' within the lisp forums in Programming Languages category; In the last section of Pratical Common Lisp, there are some functions&macros 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 ...

Go Back   Application Development Forum > Programming Languages > lisp

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 09-11-2007, 05:13 AM
daidongLY@gmail.com
Guest
 
Default Problem about 'get-internal-run-time'

In the last section of Pratical Common Lisp, there are some
functions&macros 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!

Reply With Quote
  #2  
Old 09-11-2007, 05:21 AM
Espen Vestre
Guest
 
Default Re: Problem about 'get-internal-run-time'

"daidongLY@gmail.com" <daidongLY@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)
Reply With Quote
  #3  
Old 09-11-2007, 07:13 AM
daidongLY@gmail.com
Guest
 
Default Re: Problem about 'get-internal-run-time'

On Sep 11, 5:21 pm, Espen Vestre <es...@vestre.net> wrote:
> "daidon...@gmail.com" <daidon...@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.

Reply With Quote
  #4  
Old 09-11-2007, 07:17 AM
Ken Tilton
Guest
 
Default Re: Problem about 'get-internal-run-time'



Espen Vestre wrote:
> "daidongLY@gmail.com" <daidongLY@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
Reply With Quote
  #5  
Old 09-11-2007, 07:33 AM
Espen Vestre
Guest
 
Default Re: Problem about 'get-internal-run-time'

Ken Tilton <kennytilton@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)
Reply With Quote
  #6  
Old 09-11-2007, 07:39 AM
Espen Vestre
Guest
 
Default Re: Problem about 'get-internal-run-time'

"daidongLY@gmail.com" <daidongLY@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)
Reply With Quote
  #7  
Old 09-11-2007, 11:16 AM
daidongLY@gmail.com
Guest
 
Default Re: Problem about 'get-internal-run-time'

On Sep 11, 7:39 pm, Espen Vestre <es...@vestre.net> wrote:
> "daidon...@gmail.com" <daidon...@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.

Reply With Quote
  #8  
Old 09-12-2007, 12:32 AM
Barry Margolin
Guest
 
Default Re: Problem about 'get-internal-run-time'

In article <iRuFi.7$Z%7.6@newsfe12.lga>,
Ken Tilton <kennytilton@optonline.net> wrote:

> Espen Vestre wrote:
> > "daidongLY@gmail.com" <daidongLY@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, barmar@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 ***
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 10:16 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.