Execution time mis-accounting
In the attached test case, profiling assigns a large fraction of run time to a single function. The fraction ranges from 19% to 40% across runs. Although I haven't independently verified the profile, I believe execution time is mis-attributed to this function.
The function in question is:
intersect :: Object -> Ray -> Maybe Intersection intersect obj@(Object dat mem) = objmIntersect mem dat obj
objmIntersect is a field selector. In
-ddump-simpl output, the function consists of two case statements and a function call. The function it calls has its own SCC.
In profiling, this function is usually listed as the most time-consuming function in the program. Its callee is assigned a similar amount of time. Both functions are called the same number of times. The callee computes a ray-triangle intersection, which is presumably more time-consuming than two case statements and a function call...
COST CENTRE MODULE %time %alloc intersect Datatypes 28.5 11.3 triangle.intersect Triangle 25.0 2.0 (other functions...)
I've reduced the test case from a somewhat larger ray tracer. I'm willing to help reduce it further if needed. The test case depends on the vector-space library.