Linked Questions

2
votes
0answers
1k views

Argument over performance using Convert.ChangeType in Web Applications [duplicate]

A debate has been going on at work about using Convert.ChangeType. A couple of fundamental assumptions to this discussion are delineated below: 1. The discussion is within the context of web ...
60
votes
17answers
29k views

Why use an OO approach instead of a giant “switch” statement?

I am working in a .Net, C# shop and I have a coworker that keeps insisting that we should use giant Switch statements in our code with lots of "Cases" rather than more object oriented approaches. His ...
21
votes
6answers
10k views

In general, is it worth using virtual functions to avoid branching?

There seems to be rough equivalents of instructions to equate to the cost of a branch miss virtual functions have a similar tradeoff: instruction vs. data cache miss optimization barrier If you ...
8
votes
6answers
2k views

performance versus reusability

How can I write functions that are reusable without sacrificing performance? I am repeatedly coming up against the situation where I want to write a function in a way that makes it reusable (e.g. it ...
11
votes
4answers
734 views

How to document and teach others “optimized beyond recognition” computationally intensive code?

Occasionally there is the 1% of code that is computationally intensive enough that needs the heaviest kind of low-level optimization. Examples are video processing, image processing, and all kinds of ...
3
votes
6answers
628 views

Is it better to write an efficient algorithm or code that is easier to understand?

So I was recently given a coding assignment from a large financial firm, and I thought of two ways to solve the problem. One of the ways involved 1 outer for loop and 1 inner for loop. In this case, ...
3
votes
2answers
303 views

Place variables frequently used by the same function on the heap?

Say that I have the following situation: void myFunc() { int x; //Do something with x } "x" is placed on the stack which is no doubt fast. Now, "myFunc" is called very frequently, lets say ...
1
vote
5answers
652 views

Avoiding exceptions for performance optimization

In our code base, I see a lot of code like this var error = ValidatePhoneNumber(userId, phoneNumber); //if validation fails, return error if(!string.IsNullOrEmpty(error)) { return error; } If I ...
-1
votes
2answers
390 views

conciseness to speed ratio [closed]

In general, the more concise & flexible a language is the slower is the execution of programs written in this language. on the other side, the fast languages are mostly overly verbose, requiring ...
-3
votes
2answers
891 views

What is well written code? [closed]

Is code that runs fast but written with a bad and hard to understand syntax, good code? Is code that runs slowly but written with a good and easy to understand syntax, good code?
-1
votes
1answer
165 views

Drawing the Line between Coding Style and Algorithm [closed]

Formatting with Indentations, White spaces, and New Lines obviously fit into the coding style category. if (a == b) { foo(); } // vs if (a == b) { foo(); } On the other hand, something ...