| |
comp.graphics.rendering.raytracing |
> http://www.ffconsultancy.com/free/ray_tracer/comparison.html Somewhere on an opteron 146 running debian64: real 0m13.959s # objdump -x ray > inline Vec operator+(const Vec &a, const Vec &b) { return Vec(a.x + real 0m10.493s If your point was to show how to write unbelievably inneficient code in
> I then cut this program down to a 66-line OCaml program and ported it
into a
> 97-line C++ program. These programs are compared on this page:
# g++ -g -O3 ray.cpp -o ray
# time ./ray >tt
user 0m13.946s
sys 0m0.009s
[2mn later]
# diff ray_orig.cpp ray.cpp
12,16c12,18
< Vec operator+(Vec a, Vec b) { return Vec(a.x + b.x, a.y + b.y, a.z +
b.z); }
< Vec operator-(Vec a, Vec b) { return Vec(a.x - b.x, a.y - b.y, a.z -
b.z); }
< Vec operator*(double a, Vec b) { return Vec(a * b.x, a * b.y, a *
b.z); }
< double dot(Vec a, Vec b) { return a.x*b.x + a.y*b.y + a.z*b.z; }
< Vec unitise(Vec a) { return (1 / sqrt(dot(a, a))) * a; }
---
}
# time ./ray >tt
user 0m10.483s
sys 0m0.005s
C++, you've succeeded.
Can't wait for a C++ vs Java comparison.