Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

do not call onBar() and onTick() methods in Strategy
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=83&t=50897
Page 1 of 1

Author:  ivan_taranov [ Mon 10 Mar, 2014, 23:58 ]
Post subject:  do not call onBar() and onTick() methods in Strategy

Hello! When I add IFeedListener to Strategy, I don't want to use onBar() and onTick() methods anymore.
I would like to have opportunity to force Strategy do not call them in such case. Because I want to make
my Strategy work as fast as possible, and using of this methods will be waste of time.

Author:  CriticalSection [ Tue 01 Apr, 2014, 16:18 ]
Post subject:  Re: do not call onBar() and onTick() methods in Strategy

It's likely that the fastest execution path for you is obtained by simply leaving onBar() and onTick() empty.
If the two methods are called frequently by the engine and become "Hot" as per the criteria of the JIT Compiler, both methods are likely to be re-compiled in realtime as inlined calls.
Since both methods bodies would be empty, this results in a NOOP (No Operation) and subject to further optimisation which means complete removal.
I don't have time to check if there are any default compiler flags you would have to set to guarantee this behaviour in your particular setup (such as -g:none which removes all debugging information, etc) but I would rather rely on realtime JIT optimisations than having the engine introduce conditional if statements. Without having access to the source code we can't suggest a performance conscious refactoring of the codebase to cleanly distinguish between a configuration that calls the IStrategy interfaces and one that delegates away to elsewhere. If the clock cycles used to call empty methods make that much of a difference to you, you're probably using the wrong language (C/C++?) and certainly the wrong client since JFX does a lot of things beyond simply opening a socket connection to the server side and providing callbacks.

  Page 1 of 1