0
votes
0answers
70 views

Dynamic programming in Bin packing

Problem: Given a list L of objects of possible sizes from set S={1,2,4,8} and unlimited supply of bins of sizes 16 each and we have to use minimum possible numbers of bins to pack all objects of L. I ...
3
votes
3answers
220 views

Data Oriented Design - impractical with more than 1-2 structure “members”?

The usual example of Data Oriented Design is with the Ball structure: struct Ball { float Radius; float XYZ[3]; }; and then they make some algorithm that iterates a std::vector<Ball> ...
17
votes
11answers
6k views

Does C++ compiler remove/optimize useless parentheses?

Will the code int a = ((1 + 2) + 3); // Easy to read run slower than int a = 1 + 2 + 3; // (Barely) Not quite so easy to read or are modern compilers clever enough to remove/optimize "useless" ...
3
votes
1answer
282 views

Compiler doesn't inline anything?

I've rolled my own SIMD-accelerated math library. It's gotten pretty complete, so naturally I went to conduct speed tests and optimize it. Btw this isn't premature optimization, the lib is actually ...
0
votes
2answers
373 views

What is the exact syntax of inline?

CASE 1 (Definition and declaration in same source file) Suppose both my prototype and definition of global function is in .cpp file. Where should I write inline keyword to make compiler know? In ...
7
votes
3answers
357 views

Change of the complexity class through compiler optimization?

I am looking for an example where an algorithm is apparently changing its complexity class due to compiler and/or processor optimization strategies.
4
votes
2answers
1k views

Performance and other issues with using floating point types in C++

Being interested in C++ performance programming there is one aspect I really have no clue about- and that is the implications of using floating point calculations vs doubles vs normal integer ...
4
votes
4answers
230 views

What performance topics should I be aware of? [closed]

When coding performance-critical portions of code (not necessarily large, but code that gets executed a lot), what topics should I be aware of/take into account. I'm already fairly familiar with ...
2
votes
1answer
4k views

Most efficient Implementation a Tree in C++

I need to write a tree where each element may have any number of child elements, and because of this each branch of the tree may have any length. The tree is only going to receive elements at first ...
1
vote
6answers
1k views

Can I get a C++ Compiler to instantiate objects at compile time

I am writing some code that has a very large number of reasonably simple objects and I would like them the be created at compile time. I would think that a compiler would be able to do this, but I ...
2
votes
4answers
1k views

Is using a bigger buffer useful?

I use buffer for quite a long time when I need to copy a stream or read a file. And every time I set my buffer size to 2048 or 1024, but from my point of view a buffer is like a "bucket" which ...
3
votes
4answers
378 views

Does it still make sense to think about effective code on micro scale in C++?

Early in my programming career I was in love with pointer twiddling, lean code, doing everything with as little layers of abstraction as possible and so on. The code was very C like I would say, close ...
70
votes
19answers
5k views

Is it ok to replace optimized code with readable code?

Sometimes you run into a situation where you have to extend/improve some existing code. You see that the old code is very lean, but it's also difficult to extend, and takes time to read. Is it a good ...
10
votes
4answers
564 views

Approaches against code base becoming uniformly slow

We are working on a moderately-sized C++ code base (10Mloc) which through our optimization efforts is becoming uniformly slow. This code base is a set of libraries which we combine to put them to ...
3
votes
4answers
948 views

Why is C++ known as 'premature optimizaton'? [closed]

"Programming in C++ is premature optimization" Why does everyone do some people say this?
1
vote
2answers
388 views

What is the best way to insert range of values into a datastructure

If I have a datastructure which is the fastest way I could insert values into it in a specified range? For example if I had a method: myDatastructure var=new myDataStructure(); var.insert(2,1000); ...
1
vote
3answers
220 views

What are the various premature optimizations traits / types?

For code review technique training, I have to cover various topics. One of them is premature optimization. I found 3 traits of it as: It's generally evil; causing inverse effects. It's an ...
55
votes
16answers
2k views

Why should I care about micro performance and efficency?

Many questions and answers on the C/C++ pages, specifically or indirectly discuss micro performance issues (such is the overhead of an indirect vs direct vs inline function), or using an O(N2) vs ...
13
votes
5answers
6k views

JIT compiler for C, C++, and the likes

Is there any just-in-time compiler out there for compiled languages, such as C and C++? (The first names that come to mind are Clang and LLVM! But I don't think they currently support it.) ...