Kamen TOMOV <kamen@cybuild.com> wrote:
+---------------
| Rob Warnock wrote:
| > cmu> (time (dotimes (i 2000000000)))
| > ; Compiling LAMBDA NIL:
| > ; Compiling Top-Level Form:
| >
| > ; Evaluation took:
| > ; 1.83f0 seconds of real time
| > ; 1.811377f0 seconds of user run time
| > ; 0.002219f0 seconds of system run time
| > ; 4,037,066,749 CPU cycles
| > ; 0 page faults and
| > ; 0 bytes consed.
| > ;
| > NIL
| > cmu>
| >
| > Aside: Yes, that's only 2 CPU cycles/iteration.
|
| Does the runtime mean a CPU instruction when it says CPU cycle
| in the context of instruction pipelines?
+---------------
No, it really means CPU pipeline clock cycles. On superscalar
machines such as an AMD Athlon/Opteron, one pipeline clock can
execute multiple instructions, and indeed, below is the code for
the inner loop of the DOTIMES that CMUCL generates for the above,
where those two cycles per iteration above comprise *four* instructions
[one of them a totally useless MOV, *bad* compiler!]:
cmu> (disassemble (compile nil (lambda () (dotimes (i 2000000000)))))
...
;;; [2] (DOTIMES (I 2000000000))
51: L0: INC EAX ; [:BLOCK-START]
52: L1: MOV ECX, EAX ; [:BLOCK-START]
54: CMP ECX, 2000000000
5A: JB L0
...
cmu>
Yes, I forgot to mention that I was running my examples on an
Athlon [a 2.2 GHz machine in the above case, as it happens].
Sorry 'bout that...
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607