You can't optimize what you can't measure. Learn to use perf, flamegraphs, valgrind, CPU performance counters, and build proper benchmarking frameworks.