| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| 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! |
|
#2
| |||
| |||
| "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) |
|
#3
| |||
| |||
| 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. ![]() |
|
#4
| |||
| |||
| 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 |
|
#5
| |||
| |||
| 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) |
|
#6
| |||
| |||
| "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) |
|
#7
| |||
| |||
| 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. |
|
#8
| |||
| |||
| 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 *** |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.