11 ms·
A constant reminder: Be wary when microbenchmarking functions that make relatively heavy use of lookup tables vs. those that don’t. You may not see the effects
by twoodfin 9y ago
A constant reminder: Be wary when microbenchmarking functions that make relatively heavy use of lookup tables vs. those that don’t. You may not see the effects of the pressure this adds to the data cache, but a real program using many functions and other data will.
The same is true for long vs. short functions and the instruction cache.
- Animats 9y agoIf that bothers you, there's this approach: #define VALIDTAB (0x7f00ffff) #define LENTAB (0x000000003a550000) inline bool isvalidutf8start(char c) { return((VALIDTAB >> (c>>3)) & 1); } inline unsigned utf8length(char c) { return(1+((LENTAB >> ((c>>3)*2)) & 2)); } The 32-entry table of lengths can be coded up as a 64-bit value. The "is valid" table is stored as a separate constant.