On Sunday 02 November 2008 02:52:49 Michał C wrote: > Hi! > > I'm working on a physical based ray(path) tracer and the performance > is one of my top priorities (just after the image quality). > So I have a question about optimization: can You share some tips or > maybe optimizing strategies to improve the speed of programs? > > here is my code: http://neos1.ovh.org/ray3.ml,
Now that I can profile it, the single biggest problem is obviously that seven of my cores are idle! You have manually un-nested pattern matches which is not necessary. For example, this: | Leaf (prim, mat) -> match prim with | Triangle (tri) -> ray_triangle ro rd tri | Sphere (sph) -> ray_sphere ro rd sph May be written: | Leaf (Triangle tri, mat) -> ray_triangle ro rd tri | Leaf (Sphere sph, mat) -> ray_sphere ro rd sph The only obvious optimizations I can see are to use a faster random number generator and to inline the vector arithmetic by hand. -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e _______________________________________________ Caml-list mailing list. Subscription management: http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list Archives: http://caml.inria.fr Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs