Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 2
    You also make sure you keep the original, slower, cleaner code, both as a reference implementation and to fall back on when the hardware changes and your faster, hackier code no longer works. Commented Jul 5, 2011 at 7:05
  • 5
    @PaulR How do you keep that code ? In form of comments ? That is wrong, imo - comments get outdated, nobody reads them, and personally if I see commented out code I usually remove it - this is what source control is for. A comment on a method explaining what it does is better, imo. Commented Oct 9, 2013 at 14:29
  • 5
    @Eugene: I usually keep the original version of a routine named foo and rename it foo_ref - typically it lives immediately above foo in the source file. In my test harness I call foo and foo_ref for validation and relative performance measurement. Commented Oct 9, 2013 at 14:52
  • 5
    @Paul if you are doing that might be a good idea to fail the test if the optimized version is ever slower than the ref function. this can happen if the assumptions you made to make it go faster are no longer true. Commented Nov 16, 2014 at 18:18
  • @Evgeni: I would separate code interface from its implementation. Two different implementations for the same interface (.h/.c, interface/class, it depends on the language you're using). Then switching from first impl. to second should be a matter of relinking or rerunning your code. No rename involved, more clean to me. Commented Oct 9, 2020 at 10:18