Hacker News new | ask | show | jobs
by gngeal 4722 days ago
If you're, for example, rewriting an obviously correct but slow piece of code X into a faster but not obvious code Y, how do you know if the two are functionally identical without at least some knowledge of program algebra?
1 comments

by testing and measuring performance ? In real world it is rare that you have easy way to guess actual overall impact of your optimization.

sure you profile and go for hotspots but still it is very hard to actually understand full impact and CS algorithms are done in ideal conditions so they don't address complexity of executing environment and might be misleading path for optimization.

I think the question is how can you be confident that the optimised code does exactly the same thing as the non-optimised code.