Thursday 27 December 2018

performance - What will be faster, >= or >?




I was wondering if > is faster then >= ?
I tried to benchmark it but either it takes 0ms or it takes forever.
I understand that the difference will be really small but i have to operate on a lot pixels.
Can someone tell me what is faster?



Answer



Both comparisons will be compiled to machine instructions like BLT (branch on less than) or BLE (branch on less equal), which check some status bits like BLT: N-V + -NV (negative & not overflow or not negative and overflow) or BLE: Z + N-V + -NV (zero or negative & not overflow or not negative and overflow).
These instruction take normally exactly the same time, so they are equally fast.


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...