New answers tagged performance
6
votes
C# and C++ Inheritance and Performance - Shouldn't Compilers Handle this Issue?
Investigating your underlying claim
For the purpose of example, let's say that you have a codebase where there is a MyType class, and there is also some kind of base-type-oriented logic, let's say:
...
27
votes
C# and C++ Inheritance and Performance - Shouldn't Compilers Handle this Issue?
Don't we need to take a step back here?
Under the hood, it generally all boils down to simply functions being called the with the this pointer as first arg.
It's good to question things from first ...
1
vote
C# and C++ Inheritance and Performance - Shouldn't Compilers Handle this Issue?
Why can't the compiler/jitter optimize out the call resolutions at
compile time?
It can, you help it by marking some classes as sealed, The linter also knows that if a class is internal, and has no ...
4
votes
C# and C++ Inheritance and Performance - Shouldn't Compilers Handle this Issue?
The whole point of virtual function calls is that at compile time it is unknown which code will be executed.
Swift has a partial solution: You can specify whether a class can be subclassed in a ...
12
votes
C# and C++ Inheritance and Performance - Shouldn't Compilers Handle this Issue?
Imagine this extremely simple example
A value = Random.Shared.Next(0, 2) == 0 ? new B() : new C();
value.M();
abstract class A
{
public abstract void M();
}
class B : A
{
public override ...
6
votes
C# and C++ Inheritance and Performance - Shouldn't Compilers Handle this Issue?
Why can't the compiler/jitter optimize out the call resolutions at compile time?
It can in some cases, but there are reasonable scenarios that preclude compile-time identification of the proper ...
2
votes
Accepted
How do function inlining and Tail Call Optimization affect call stack?
AFAIK every function call adds a new stack frame into a call stack.
This is true for some functions, but not for all functions. On some processors, simple functions, called leaf functions (functions ...
0
votes
Accepted
Build an API for a graph app with + 30 millions data points
I think you might be making this a more difficult than it is. You have M data points to show on a chart. You can only actually display N data points at a time. You simply need to divide your point ...
0
votes
Build an API for a graph app with + 30 millions data points
The usual approach for allowing different zoom levels for 2D graphics is to use a tree-like data structure (for example a quadtree), or for a one-dimensional time-series just a binary tree, where you ...
0
votes
How can I make code that is both DRY and fast where intermediate values in a calculation may or may not be needed?
Newcomer developers have a tendency to copy/paste code and not realize that there's an opening for reusability. Intermediate developers understand the importance of reusability and apply it to ...
14
votes
Accepted
How can I make code that is both DRY and fast where intermediate values in a calculation may or may not be needed?
I would consider the following alternatives, in that order:
Start with the DRY variant, even it is less efficient. In most real-world cases, this won't matter. If a benchmark tells you here is your ...
Top 50 recent answers are included
Related Tags
performance × 831java × 90
algorithms × 72
c++ × 70
design × 69
database × 59
optimization × 56
architecture × 54
c# × 52
javascript × 41
python × 30
php × 29
web-development × 27
c × 26
caching × 26
design-patterns × 25
sql × 25
multithreading × 25
object-oriented × 22
memory × 21
scalability × 20
programming-practices × 19
data-structures × 19
.net × 18
programming-languages × 18