The splendour and poverty of the PLO - page 4

 
Integer:

... The assumption is that this case should work very quickly, because there are no if and switch calls to change the way the program works, only once the required class - descendant is selected during initialisation, then everything works straightforwardly and easily.

...

MetaDriver:

...

In languages with "real" pointers there will be no such effect, switch will lose there, the bigger is selection list.

...

Guys, smoke the switch documentation. A good switch is a switched transition whose performance does not depend on the number of choices. 1 choice, 100 or 1000 - its transition speed will be constant.
Как работает оператор switch в Си/Си++ - CyberForum.ru - форум программистов и сисадминов
  • Evg
  • www.cyberforum.ru
ВНИМАНИЕ! Вопросы по существу обсуждаемого вопроса просьба задавать здесь или создать тему на форуме и кинуть на неё ссылку в блог или мне в личку. Причин для этого несколько. Я, как и любой другой автор, всегда могу упустить интересный момент обсуждаемой темы (что подтвердилось на практике). А потому задаваемый вопрос может закрывать...
 
Integer:
Why do I need to understand the compilation mechanisms? Just to believe that a bad result is better than a good one?

That's a strange statement. You're trying to solve compiler-level optimization problems and yet you don't know how the compiler works.

 
C-4:
Guys, read the switch documentation. A good switch is a switched transition whose performance does not depend on the number of choices. 1 choice, 100 or 1000 - its transition speed will be constant.
Yes, we have switch with direct table jumping if there are enough elements as in the examples.
 

I am very close to zero in programming and I know that OOP is made more for convenience than for speed. And it's true - OOP is a handy thing, if you know how to use it.

On the other hand, it's better for metaquotes to spend time on incorrect spreads in the tester. There is no sense in writing EAs using it if you cannot test them adequately. Most of it applies to trading on FORTS.

 
dimeon:

I am close to zero in programming and I know that OOP is made more for convenience than for speed. And it's true - OOP is a handy thing, if you know how to use it.

On the other hand, it's better for metaquotes to spend time on incorrect spreads in the tester. There is no sense in writing EAs using it if you cannot test them adequately. This mostly concerns trading on FORTS.

Have you already given a detailed explanation (proof) somewhere?

Here it is customary to substantiate your statements with evidence, otherwise you won't even look at them. ;)

 

And in general, the example of the top-starter shows that there is inlining. Without it, in debug mode, the results are reversed and OOP is faster:

This picture hints that the comrades are searching for a black cat in a dark room.

 
Renat:

...

The virtual method, on the other hand, cannot be cut out - it is always called. As a result, in one case there is just a loop, and in the other case there is a call in the loop.

...

By the way, you may delete empty loops as well. Code:

void OnStart(){
   for(int i = 0; i < 1000000; i++)
      foo();
}

void foo(void){}

Can be reduced to a simple one:

void OnStart(){
   ;
}
 
Vinin:

The evidence will come from the other side. Or again just words.

By and large, I'm only interested in facts.

Although I already know that OOP is slower, but it provides quite concrete conveniences

On Monday I'll show by an example of profiling real OOP-project that its performance in the limit tends to the system functions calls performance.
 
C-4:

That's a strange statement. You're trying to solve compiler-level optimisation problems and yet you don't know how it works.

Sorry, you've got something mixed up, I wasn't trying to optimize the compiler. If you don't understand what I was doing, try to reread this thread from the beginning again, but more carefully, and also try not to get clever off-topic.
 
Renat:
Yes, we have a switch with a direct jump over the table if there are enough elements, as in the examples.

The examples in this example take the simplest variant, where the key values are in single increments, so the offset is simply calculated. But if we have such a variant:

case 10: ...

case 100: ... case 1000: ... case 1000000: ...

Here, as I understand it, the index is defined through binary search. Do you have both of these methods?