[racket] values primitive blocks future execution
Hi James,
> sph-list is a list, and you are using for/fold to iterate over the
> elements in the list (inside a future). This is problematic for a number of
> reasons;
>
could you pls elaborate on that? why there would be any performance
implications on iterating over immutable list inside the future?
> instead, you could convert it to a vector (or just change your definition
> to use a vector) and change `ray-cast' accordingly:
>
> (define (ray-cast x y object-list)
> (let ([view-ray (screen-ray x y)])
> (define closest-int (int-res #f 10000.0 null-point))
> (for ([i (in-range 0 (vector-length object-list))])
> (define obj (vector-ref object-list i))
> (set! closest-int (get-closer-res closest-int
> (hit-sphere3D view-ray obj))))
> closest-int))
>
i've changed list of objects -> vector of objects and used your
implementation.
and with (time (run-no-render))
i get these results:
cpu time: 3595 real time: 3591 gc time: 52
but, on keeping list implementation and adding in-list to for i get these:
cpu time: 3186 real time: 3184 gc time: 26
the change:
+ ([obj (in-list object-list)])
- ([obj object-list])
> Also, there are two places where I think you may have forgotten to use
> flonum primitives (on lines 99 and 100) -- just change `sqrt' to `flsqrt',
> as you have done elsewhere in the code.
>
>
right! thanks.
>
> --
With best regards,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130222/634dfe99/attachment-0001.html>