Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Profiling

npsimons (32752) writes | more than 4 years ago

User Journal 3

No, not the racial kind. This has to do with code efficiency. I was recently writing patch acceptance guidelines, and was trying to explain that maintainability matters far more than efficiency. I was trying to be polite about people who harp on "efficiency", but my basic feelings boil down to: "People who talk about software efficiency, yet aren't familiar with software profiling, are idiots." Discuss.

No, not the racial kind. This has to do with code efficiency. I was recently writing patch acceptance guidelines, and was trying to explain that maintainability matters far more than efficiency. I was trying to be polite about people who harp on "efficiency", but my basic feelings boil down to: "People who talk about software efficiency, yet aren't familiar with software profiling, are idiots." Discuss.

cancel ×

3 comments

Sorry! There are no comments related to the filter you selected.

Depends on the actual use (1)

Marxist Hacker 42 (638312) | more than 4 years ago | (#31064286)

I've seen code written for "maintainability" that ended up so complex it couldn't be maintained anyway.

I've seen code so efficient, that it can't be ported even to the next generation CPU because it depended on bugs that no longer exist in the microcode.

I say, far better than arguing between efficiency and maintainability, is KISS- keep it simple stupid.

If you have a function that runs over a page of printout, it needs to be broken up into sub functions.

If you're using inheritance, also use comments to keep the code traceable by a human being without a computer.

If what you are calling can't be found with a simple text search, then your code has become too complex and you need to refactor.

If you can't profile by hand, then you either need to learn more about how your compiler is actually translating your instructions into p-code or machine language, OR your system has gotten too complex to maintain. One or the other.

Re:Depends on the actual use (1)

npsimons (32752) | more than 4 years ago | (#31075914)

I say, far better than arguing between efficiency and maintainability, is KISS- keep it simple stupid.

There are some (myself included) that would argue that simple code is more readable *and* generally easier for compilers to optimize. Therefore, I would agree that the KISS principle should reign supreme.

Then there are some I've gotten into arguments with (the aforementioned "efficiency experts" who have never heard of profiling) who think that tweaking variables and unrolling loops by hand will make a piece of code faster than if you ran it through "gcc -O3". It gets especially ludicrous when they suggest they can write better assembler than the compiler, but they can't even cite the cache size of one (of many!) CPUs that they might want to "optimize" their code for. These people have also argued that 1000 line functions are "more efficient" and then stare at me blankly when I ask them if they know what inlining means.

I've also had to maintain far too much software written by people who obviously didn't know what their compiler was doing, and not only made their code more obfuscated by "optimizing" it, but made it impossible to run fast, thereby defeating both readability and efficiency. I'm thoroughly convinced that the only reason refactoring is as big as it is is because of far too much code like this.

Re:Depends on the actual use (1)

Marxist Hacker 42 (638312) | more than 4 years ago | (#31076520)

Inlining is only more efficient if you're only calling a function from a single place. Otherwise the maintenance hit will far outweigh the efficiency you'll get in code.

I'm currently stuck in exactly such a project- one where an addiction to XML and inheritance has made the code all but unmaintainable. And worse yet, the company I'm contracting with refuses to give me more than 20 hours a week to work on it.

Check for New Comments
Slashdot Login

Need an Account?

Forgot your password?