I suggest that if you're THAT interesting in LEARNING optimization, start coding in assembly.
I'm talking about implementing matrix 4x4 concatenation using assembly, a transform & lighting pipeline in assembly, a DCT (Discrete Cosine Transform).
You may or may not write something faster than a well written C code, but the learning experience is rich.
For example, when I implemented my own matrix 4x4 concatenation in assembly, I learned about subtleties of the architecture of the code and language. My function was failing when I was doing concat4x4( &result, &matrixA, &matrixA ); but worked correct when doing concat4x4( &result, &matrixA, &matrixB );
After lots of debugging, I realized my math was correct, but my code assumed that matrixA & matrixB weren't pointing to the same memory and I was overwriting the values as I wrote them. I had to clone the matrix before I made the concat; unless I could guarantee matrixA & matrixB arguments wouldn't overlap. That was far more valuable than any micro-optimization and stuff like this can really hurt your application's performance. I was learning, by myself (and by accident), the concept of the restrict keyword
Like I said, modern architectures are very complex. And your "lab" experiments of benchmarking code without context is useless (because neither branch predictors nor caches are stateless).
To picture how complex modern CPUs are, here's an example of an Intel i7 anomaly, where adding a call instruction actually made the program run faster.
One would think, adding an instruction should make the program slower. Most likely the reason behind this are loads blocked due to store forwarding. Considering you didn't know what a branch was, I won't explain what load-store forwarding is, as it is extremely low level (and I'm actually guessing, the reason behind the anomaly could be something else).
Let me tell like this : i have tested all this, get the time, repeat 1000 times, then get the time again.
Test showed me the simplest if was faster then functions, it was a while ago, i should test it again on my new pc maybe ?
My tests also show me that the sun probably moves around the earth, that doesn't mean I'm right.
Is that a problem ?, i thought questions are never dumb, i skip learning everything that is not needed to get result, if i need something i can Always ask it.
We value smart, well asked questions. But that attitude won't get you anywhere. We value MUCH more people who can solve problems by themselves and ask questions to others as a last resort, after you've exhausted all your other alternatives (trial and error, books, manuals, papers, other people's code i.e. open source, google and wikipedia).
But if you defending your own business, ofcourse you dont wanto tell the competition how to get your games optimized,
This industry wouldn't be anywhere if people hadn't share their experiences and explain to others what they did in detail. Many companies and individuals share their latest next-gen techniques on GDC and SIGGRAPH for everyone to reproduce (that includes big names such as CryTek, Unreal, Ubisoft, Naughty Dog, Eidos, Square Enix, Valve, Microsoft, Sony, AMD, NVIDIA, Intel) and that helped moved the industry forward.
You're thinking it backwards.