anchor.diff:  
   
   ;;;
  -;;; Performance measurement functions
  +;;; Performance displayment functions
   ;;;
   
   (defvar *flops-per-interaction* 20)
   
  -(defun compute-perf-stats (num-bodies elapsed-time fps-count iterations)
  -  (let ((milliseconds (/ elapsed-time fps-count)))
  -    (let* ((ifps (/ 1.0 (/ milliseconds 1000.0)))
  -           (interactions-per-second (/ (* num-bodies num-bodies iterations)
  -                                       (/ milliseconds 1000)
  -                                       1.0e9))
  -           (gflops (* interactions-per-second *flops-per-interaction*)))
  -      (values ifps interactions-per-second gflops))))
  +(defun compute-perf-stats (num-bodies fps iterations)
  +  (let* ((interactions-per-second (/ (* num-bodies num-bodies iterations)
  +                                     (/ 1.0 fps)
  +                                     1.0e9))
  +         (gflops                  (* interactions-per-second *flops-per-interaction*)))
  +    (values interactions-per-second gflops)))
   
   (let ((fps-count 0)
         (fps-limit 5)
         (template "CUDA N-Body (~A bodies): ~,1F fps | ~,1F BIPS | ~,1F GFLOP/s | single precision~%"))
  -  (defun display-frame-rate (num-bodies)
  +  (defun display-frame-rate (num-bodies fps)
       (incf fps-count)
       (when (>= fps-count fps-limit)
  -      (multiple-value-bind (ifps interactions-per-second gflops)
  -          (compute-perf-stats num-bodies (get-elapsed-time) fps-count 1)
  -        (glut:set-window-title
  -          (format nil template num-bodies ifps interactions-per-second gflops))
  -        (setf fps-count 0)
  -        (setf fps-limit (max ifps 1.0))))))
  -
  -
  -;;;
  -;;; Timing functions
  +      (multiple-value-bind (interactions-per-second gflops)
  +          (compute-perf-stats num-bodies fps 1)
  +        (format t template num-bodies fps interactions-per-second gflops)
  +        (glut:set-window-title (format nil template num-bodies fps interactions-per-second gflops)))
  +      (setf fps-count 0
  +            fps-limit (max fps 1.0)))))
  +
  +
  +;;;
  +;;; Frame rate counter
  +;;;
  +
  +(let ((fps-count 0)
  +      (fps-limit 5)
  +      (fps       0))
  +  
  +  (defun frame-rate-counter-init ()
  +    (create-timer-events)
  +    (start-timer))
  +  
  +  (defun frame-rate-counter-release ()
  +    (destroy-timer-events))
  +  
  +  (defun frame-rate-counter-get-frame-rate ()
  +    fps)
  +  
  +  (defun frame-rate-counter-measure ()
  +    (incf fps-count)
  +    (when (>= fps-count fps-limit)
  +      (let ((milliseconds (/ (get-elapsed-time) fps-count)))
  +        (setf fps       (/ 1.0 (/ milliseconds 1000.0))
  +              fps-count 0
  +              fps-limit (max fps 1.0))))))
  +
  +
  +;;;
  +;;; Timer functions
   ;;;
   
   (let ((start-event (cffi:null-pointer))
  
positive.code: ;;;
  
  (defmethod glut:display-window :before ((w nbody-window))
    (gl:enable :depth-test)
    (gl:clear-color 0 0 0 0)
    (nbody-demo-init))
  
  (defmethod glut:display-window :after ((w nbody-window))
    (nbody-demo-release))
  
  (defmethod glut:display ((w nbody-window))
    (with-slots (new-pos old-pos vel delta-time damping num-bodies p) w
      ;; update simulation
      (nbody-demo-update-simulation new-pos old-pos vel delta-time damping num-bodies p)
      (rotatef new-pos old-pos)
      ;; clear buffers
      (gl:clear :color-buffer :depth-buffer-bit)
      ;; view transform
      (gl:matrix-mode :modelview)
      (gl:load-identity)
      (gl:translate 0.0 0.0 -100.0)
      (gl:rotate 0.0 1.0 0.0 0.0)
      (gl:rotate 0.0 0.0 1.0 0.0)
      ;; display bodies
      (nbody-demo-display new-pos num-bodies)
      ;; swap buffers
      (glut:swap-buffers)
      ;; display frame rate
      (display-frame-rate num-bodies)))
  
  (defmethod glut:reshape ((w nbody-window) width height)
    ;; configure on projection mode
  
negative.code: 
    (defun get-elapsed-time ()
      (let (milliseconds)
        (stop-and-synchronize-timer)
        (cffi:with-foreign-object (pmilliseconds :float)
          (cu-event-elapsed-time pmilliseconds
                                 (cffi:mem-ref start-event 'cu-event)
                                 (cffi:mem-ref stop-event 'cu-event))
          (setf milliseconds (cffi:mem-ref pmilliseconds :float)))
        (start-timer)
        milliseconds)))
  
  (defmacro with-cuda-timer (&body body)
  