Raytracing speed again, this time with gdc. -- "oops" remedied
downs
default_357-line at yahoo.de
Thu Nov 8 08:34:55 PST 2007
Jascha Wetzel wrote:
> downs wrote:
>> Here we go again.
>>
>> D version.
>>
>> Each sample counts as 0.01 seconds.
>> % cumulative self self total
>> time seconds seconds calls s/call s/call name
>> 73.09 5.08 5.08 6164146 0.00 0.00 void
>> ray1.Group.intersect(inout typedef ray1.Hit, inout struct ray1.Ray,
>> void*)
>> 19.57 6.44 1.36 38551270 0.00 0.00 void
>> ray1.Sphere.intersect(inout typedef ray1.Hit, inout struct ray1.Ray,
>> void*)
>> 3.74 6.70 0.26 1 0.26 6.88 _Dmain
>> 2.59 6.88 0.18 4194304 0.00 0.00 double
>> ray1.ray_trace(inout struct ray1.Vec, inout struct ray1.Ray, class
>> ray1.Scene)
>> 0.43 6.91 0.03 struct gcx.Pool*
>> gcx.Gcx.findPool(void*, void*)
>> 0.14 6.92 0.01 void*
>> gcx.GC.mallocNoSync(uint, void*)
>> 0.14 6.93 0.01 uint
>> gcbits.GCBits.test(uint, void*)
>> 0.14 6.94 0.01 _d_callfinalizer
>> 0.14 6.95 0.01 _d_newclass
>> 0.00 6.95 0.00 1 0.00 0.00 void
>> ray1._staticCtor1()
>> 0.00 6.95 0.00 1 0.00 0.00 class ray1.Scene
>> ray1.create(int, inout struct ray1.Vec, double)
>> 0.00 6.95 0.00 1 0.00 0.00 void
>> ray1.__modinit()
>>
>> C++ version.
>>
>> Each sample counts as 0.01 seconds.
>> % cumulative self self total
>> time seconds seconds calls ms/call ms/call name
>> 76.88 4.19 4.19 6164146 0.00 0.00
>> Group::intersect(std::pair<double, Vec>&, Ray const&) const
>> 18.35 5.19 1.00 38551282 0.00 0.00
>> Sphere::intersect(std::pair<double, Vec>&, Ray const&) const
>> 3.30 5.37 0.18 main
>> 1.28 5.44 0.07 4194304 0.00 0.00 ray_trace(Vec
>> const&, Ray const&, Scene const&)
>> 0.18 5.45 0.01 1 10.00 10.00 create(int, Vec
>> const&, double)
>> 0.00 5.45 0.00 87381 0.00 0.00 Sphere::~Sphere()
>> 0.00 5.45 0.00 1 0.00 0.00 global
>> constructors keyed to real
>> 0.00 5.45 0.00 1 0.00 0.00
>> __static_initialization_and_destruction_0(int, int)
>> 0.00 5.45 0.00 1 0.00 0.00 Group::~Group()
>
> in Sphere.intersect, instead of
> hit = Hit(lambda, (ray.orig + lambda*ray.dir - center).unitise);
> try
> hit.first = lamdba;
> hit.second = ...
> it might not optimize away the creation on stack + copy.
>
I just tried that. Negligible change.
> now i'd look at the asm code for ray_sphere in both versions, since that
> seems to where the time is burnt.
>
> also curious: why does the C++ version call Sphere::intersect 12 times
> more often than the D version?
I'd like to know that as well. Far as I know, the algorithm's the same.
I'll add debugging code to find out.
--downs
More information about the Digitalmars-d-learn
mailing list