|
When generating partial products, a performance enhancement could be generated by considering the special case where a trit having the value 0 is multiplied by an xreal. In this case, the resulting xreal is just a stream of zeroes.
Another special case is when the trit has a value of 1. The resulting xreal is just the xreal taken. Seeing that these trits appear frequently this optimization is recommended. (define (mult_xreal_int xr i) (cond ((= i 0) zeroes) ((= i 1) xr) (else (stream-map (lambda (trit) (* trit i)) xr))))This procedure could go in place of Ben Singer's mult_trit_stream procedure. The reason for a performance enhancement is not having to do a stream-map over the xreal. On my current implementation (optimization in progress) I get the following results:
(comp_time (repeat_mult (rational->xreal 1112/1111) (rational->xreal 1/2) 5) #t) ;Before: ;Run time: 510 ;GC time: 40 ;Real time: 549 ;Value 73: (0 . #[promise 74]) ;After: (I ran the optimized procedure first by mistake) ;Run time: 150 ;GC time: 0 ;Real time: 146 ;Value 71: (0 . #[promise 72]) |
Better test by Mark Kittisopikul, 2002, Nov 25
to: