(defstruct SPerson name age ) (defclass CPerson()( (nam […]
(defstruct SPerson name age ) (defclass CPerson()( (nam […]
(defstruct SPerson name age ) (defclass CPerson()( (name :initarg :name :accessor :name) (age :initarg :age) )) (let (bob (n 10000000)) (format t "~%(make-SPerson):~A~%" (setf bob (make-SPerson :name "Bob" :age 25))) (time(loop repeat n do (make-SPerson :name "Bob" :age 25))) (format t "~%(SPerson-name bob):~A~%" (SPerson-name bob)) (time(loop repeat n do (SPerson-name bob))) (format t "~%(make-instance 'CPerson):~A~%" (setf bob (make-instance 'CPerson :name "Bob" :age 25))) (time(loop repeat n do (make-instance 'CPerson :name "Bob" :age 25))) (format t "~%(:name bob):~A~%" (:name bob)) (time(loop repeat n do (:name bob))) (format t "~%(slot-value bob 'name):~A~%" (slot-value bob 'name)) (time(loop repeat n do (slot-value bob 'name))) ) (quit) #| (ClozureCL) (make-SPerson):#S(SPERSON :NAME Bob :AGE 25) (LOOP REPEAT N DO (MAKE-SPERSON :NAME "Bob" :AGE 25)) took 265,000 microseconds (0.265000 seconds) to run. 12,300 microseconds (0.012300 seconds, 4.64%) of which was spent in GC. During that period, and with 4 available CPU cores, 234,375 microseconds (0.234375 seconds) were spent in user mode 0 microseconds (0.000000 seconds) were spent in system mode 320,000,064 bytes of memory allocated. (SPerson-name bob):Bob (LOOP REPEAT N DO (SPERSON-NAME BOB)) took 9,000 microseconds (0.009000 seconds) to run. During that period, and with 4 available CPU cores, 15,625 microseconds (0.015625 seconds) were spent in user mode 0 microseconds (0.000000 seconds) were spent in system mode 64 bytes of memory allocated. (make-instance 'CPerson):#<CPERSON #x2100619C3D> (LOOP REPEAT N DO (MAKE-INSTANCE 'CPERSON :NAME "Bob" :AGE 25)) took 6,937,000 microseconds (6.937000 seconds) to run. 31,695 microseconds (0.031695 seconds, 0.46%) of which was spent in GC. During that period, and with 4 available CPU cores, 6,859,375 microseconds (6.859375 seconds) were spent in user mode 15,625 microseconds (0.015625 seconds) were spent in system mode 640,000,064 bytes of memory allocated. (:name bob):Bob (LOOP REPEAT N DO (:NAME BOB)) took 198,000 microseconds (0.198000 seconds) to run. During that period, and with 4 available CPU cores, 203,125 microseconds (0.203125 seconds) were spent in user mode 0 microseconds (0.000000 seconds) were spent in system mode 64 bytes of memory allocated. (slot-value bob 'name):Bob (LOOP REPEAT N DO (SLOT-VALUE BOB 'NAME)) took 134,000 microseconds (0.134000 seconds) to run. During that period, and with 4 available CPU cores, 125,000 microseconds (0.125000 seconds) were spent in user mode 0 microseconds (0.000000 seconds) were spent in system mode 64 bytes of memory allocated. (SBCL) (make-SPerson):#S(SPERSON :NAME Bob :AGE 25) Evaluation took: 0.153 seconds of real time 0.156250 seconds of total run time (0.156250 user, 0.000000 system) [ Run times consist of 0.031 seconds GC time, and 0.126 seconds non-GC time. ] 101.96% CPU 487,882,134 processor cycles 320,012,176 bytes consed (SPerson-name bob):Bob Evaluation took: 0.009 seconds of real time 0.000000 seconds of total run time (0.000000 user, 0.000000 system) 0.00% CPU 30,012,445 processor cycles 0 bytes consed (make-instance 'CPerson):#<CPERSON {1002A85623}> Evaluation took: 0.196 seconds of real time 0.203125 seconds of total run time (0.203125 user, 0.000000 system) [ Run times consist of 0.016 seconds GC time, and 0.188 seconds non-GC time. ] 103.57% CPU 14 lambdas converted 625,230,977 processor cycles 640,351,952 bytes consed (:name bob):Bob Evaluation took: 0.047 seconds of real time 0.046875 seconds of total run time (0.046875 user, 0.000000 system) 100.00% CPU 150,816,650 processor cycles 0 bytes consed (slot-value bob 'name):Bob Evaluation took: 0.048 seconds of real time 0.046875 seconds of total run time (0.046875 user, 0.000000 system) 97.92% CPU 149,533,983 processor cycles 0 bytes consed |#