[Openmcl-devel] char= slower than eql?

David Tolpin dvd at davidashen.net
Sat Apr 9 11:56:59 PDT 2005


? (time (let ((x #\a)) (dotimes (i 1000000) (eql x (character (mod i 
128))))))
(LET ((X #\a)) (DOTIMES (I 1000000) (EQL X (CHARACTER (MOD I 128))))) 
took 761 milliseconds (0.761 seconds) to run.
Of that, 650 milliseconds (0.650 seconds) were spent in user mode
          10 milliseconds (0.010 seconds) were spent in system mode
          101 milliseconds (0.101 seconds) were spent executing other OS 
processes.
NIL
? (time (let ((x #\a)) (dotimes (i 1000000) (char= x (character (mod i 
128))))))
(LET ((X #\a)) (DOTIMES (I 1000000) (CHAR= X (CHARACTER (MOD I 128))))) 
took 821 milliseconds (0.821 seconds) to run.
Of that, 730 milliseconds (0.730 seconds) were spent in user mode
          10 milliseconds (0.010 seconds) were spent in system mode
          81 milliseconds (0.081 seconds) were spent executing other OS 
processes.
NIL
?

This is consistent (I wrote the loop to avoid optimizations of constant 
expressions), and this is the cause. Why is char= slower than eql? Two 
times slower, actually:

? (declaim (optimize (speed 0) (safety 3) (debug 3)))
NIL
? (time (dotimes (i 1000000) (eql #\a x)))
(DOTIMES (I 1000000) (EQL #\a X)) took 224 milliseconds (0.224 seconds) 
to run.
Of that, 170 milliseconds (0.170 seconds) were spent in user mode
          0 milliseconds (0.000 seconds) were spent in system mode
          54 milliseconds (0.054 seconds) were spent executing other OS 
processes.
NIL
? (time (dotimes (i 1000000) (char= #\a x)))
(DOTIMES (I 1000000) (CHAR= #\a X)) took 459 milliseconds (0.459 
seconds) to run.
Of that, 380 milliseconds (0.380 seconds) were spent in user mode
          0 milliseconds (0.000 seconds) were spent in system mode
          79 milliseconds (0.079 seconds) were spent executing other OS 
processes.
NIL
?

David




More information about the Openmcl-devel mailing list