4 ms·
> avoid div instructions in favour of floating point multiply. > Is this still faster on recent CPUs? NB - >>[Taking this question out of context]<< - looks
by kees99 9y ago
> avoid div instructions in favour of floating point multiply.
> Is this still faster on recent CPUs?
NB - >>[Taking this question out of context]<< - looks like the answer is "no". From a quick test:
- intel Broadwell: 64-bit integer div is fastest, float div is 69% slower, float mul is 50% slower;
- AMD Ryzen: 64-bit integer div is fastest, float div is 47% slower, float mul is 60% slower;
- ARM11 (Raspberry Zero): 64-bit integer div is fastest, float div is 138% slower, float mul is 159% slower.
quick-and-dirty test used: https://pastebin.com/raw/4XqnuXL5 https://pastebin.com/raw/4XqnuXL5
- apjana 9y agoWe don't have the case of integer div. And if you take a look into the coolsize() func we don't re-compute the factor. So it's not very significant. To get the size of a file we multiply only once with this factor. What is significant is the while() loop where the iterations increase with the file size. There's no mul or div in it giving the API a reasonable performance benefit.