When I set out to create my own WebGL 3D library for learning purposes, I followed documentation from various sources claiming that the set()
function for Float32Array
was touted as being "as fast as" memcpy in C and the fastest option according to html5rocks. However, upon testing, it appeared that this function was actually much slower compared to other techniques.
Upon further investigation, I looked into glMatrix, where the author had optimized their library by unrolling loops for speed. Even though this is a common practice for maximizing performance, I still believed that utilizing the set()
function would provide me with the best results since I intended to work exclusively with TypedArray
types.
To put my theory to the test, I created a jsperf benchmark. Surprisingly, not only did the set()
function turn out to be significantly slower, but every other method I experimented with surpassed it in terms of speed. This led me to question why this supposedly efficient function was performing so poorly.
Ultimately, my question remains: Why is the set()
function underperforming? Could it be an issue with my code, my browser (Firefox 24), or am I overlooking some key optimization strategy? Any insights or explanations on this unexpected outcome would greatly benefit my understanding.