Browse code
Benchmarking vm changes
Ed Langley authored on 09/10/2018 05:50:04
Showing 2 changed files
Showing 2 changed files
... | ... |
@@ -79,7 +79,7 @@ |
79 | 79 |
(let ((obj-dist (point-x origin)) |
80 | 80 |
(r_sqr (expt radius 2))) |
81 | 81 |
(lambda (point &optional out-point extracted-point) |
82 |
- ;(declare (inline) (optimize (speed 3))) |
|
82 |
+ (declare (inline) (optimize (speed 3))) |
|
83 | 83 |
(let* ((out-point (or out-point (make-point :x 0 :y 0 :z 0))) |
84 | 84 |
(point (or extracted-point (extract-projected-point point obj-dist out-point)))) |
85 | 85 |
(let ((d_o (c-distance origin point))) |
... | ... |
@@ -92,12 +92,30 @@ |
92 | 92 |
0) |
93 | 93 |
point)))))) |
94 | 94 |
|
95 |
+(defun make-interesting-cb (origin radius) |
|
96 |
+ (let ((obj-dist (point-x origin)) |
|
97 |
+ (r_sqr (expt radius 3))) |
|
98 |
+ (lambda (point &optional out-point extracted-point) |
|
99 |
+ (declare (inline) (optimize (speed 3))) |
|
100 |
+ (let* ((out-point (or out-point (make-point :x 0 :y 0 :z 0))) |
|
101 |
+ (point (or extracted-point (extract-projected-point point obj-dist out-point)))) |
|
102 |
+ (let ((d_o (c-distance origin point))) |
|
103 |
+ (values (if (<= d_o radius) |
|
104 |
+ (ceiling (* (/ (expt (- r_sqr |
|
105 |
+ (expt d_o |
|
106 |
+ 3)) |
|
107 |
+ 0.33) |
|
108 |
+ radius) |
|
109 |
+ #. (expt 2 7))) |
|
110 |
+ 0) |
|
111 |
+ point)))))) |
|
112 |
+ |
|
95 | 113 |
(defun make-donut-cb (origin radius width) |
96 | 114 |
(let ((pos-cb (make-sphere-cb origin radius)) |
97 | 115 |
(neg-cb (make-neg-sphere-cb origin (- radius width))) |
98 | 116 |
(obj-dist (point-x origin))) |
99 | 117 |
(lambda (point &optional out-point) |
100 |
- ;(declare (inline) (optimize (speed 3))) |
|
118 |
+ (declare (inline) (optimize (speed 3))) |
|
101 | 119 |
(let* ((out-point (or out-point (make-point :x 0 :y 0 :z 0))) |
102 | 120 |
(extracted-point (extract-projected-point point obj-dist out-point))) |
103 | 121 |
(+ (funcall pos-cb point out-point extracted-point) |
... | ... |
@@ -162,12 +180,11 @@ |
162 | 180 |
|
163 | 181 |
(defun main (&rest args) |
164 | 182 |
(declare (ignore args)) |
165 |
- ;(sb-profile:profile intercept-coordinate c-distance) |
|
183 |
+ ;;(sb-profile:profile intercept-coordinate c-distance) |
|
166 | 184 |
(let ((the-plane (make-instance 'plane |
167 |
- :cells (make-array '(2048 2048)) |
|
185 |
+ :cells (make-array '(512 512)) |
|
168 | 186 |
:distance 50)) |
169 |
- (lparallel:*kernel* (lparallel:make-kernel 32)) |
|
170 |
- (sphere (make-instance 'shape))) |
|
187 |
+ (lparallel:*kernel* (lparallel:make-kernel 8))) |
|
171 | 188 |
|
172 | 189 |
(labels ((100- (x) (- x 100)) |
173 | 190 |
(random-coord () (100- (random 200)))) |
... | ... |
@@ -175,9 +192,12 @@ |
175 | 192 |
(run-plane the-plane |
176 | 193 |
(apply #'combine-shapes |
177 | 194 |
(loop for _ from 0 to 100 |
178 |
- collect (defshape make-sphere-cb |
|
179 |
- (vector (1+ (random 50)) (random-coord) (random-coord)) |
|
180 |
- (+ 3 (random 30)))))))) |
|
195 |
+ collect (defshape make-donut-cb |
|
196 |
+ (vector (1+ (random 50)) |
|
197 |
+ (random-coord) |
|
198 |
+ (random-coord)) |
|
199 |
+ (+ 3 (random 30)) |
|
200 |
+ 3)))))) |
|
181 | 201 |
|
182 | 202 |
(with-open-file (s "/tmp/spheres.pgm" :direction :output :if-exists :supersede) |
183 | 203 |
(write-sequence (array-to-pgm (cells the-plane)) |