5 ms·
> you would have to stop and think "I can't allocate _my_ byte type! I must allocate u8 No, this is premature optimization. Rather, you would write the code in
by catlifeonmars 5y ago
> you would have to stop and think "I can't allocate _my_ byte type! I must allocate u8
No, this is premature optimization. Rather, you would write the code in the most obvious way, and then profile it to figure out which optimizations are worth doing. At that point you can comment your code explaining why it looks all wonky :)
- HexDecOctBin 5y agoAnd applying this thinking everything means that your entire code is pervaded with slowness with no obvious hot spots, and you jump with joy since it obviously means that your code is as efficient as it possibly could be (because otherwise the profiler will show some peaks, right?).
- catlifeonmars 5y agoI know this was meant as (light) sarcasm, but have you ever profiled a nontrivial program that turned out to have zero peaks? My gut tells me this would be really difficult to do by accident. The same way that writing crypto code that is resistant to timing attacks is hard.
- HexDecOctBin 5y agoI have definitely seen code where the peaks are very shallow, and flattening them does nothing for the performance.
- hsn915 5y agoYou only need to encounter this problem a few times before you stop trusting the compiler at all.