Wealth-Lab strategy performance profiling
Author: avishn
Creation Date: 10/23/2009 7:45 AM
profile picture

avishn

#1
First just to avoid any confusion... I'm talking about application/script performance in terms of CPU cycles, not performance of a trading strategy.

For those of you who are into multiparameter strategy optimization or just have CPU-intensive scripts like I do... You might find this helpful.

It appears that a free/open source NProf .NET profile (http://code.google.com/p/nprof/) can be used to profile Wealth-Lab scripts. NProf is extremely minimalistic in its interface and features, but it gets the job done. After downloading and installing you just need to start Wealth-Lab from within the profiler, open your script, run it and then close Wealth-Lab. You will see a typical hierarchical performance profiling results as a tree of executed methods with method timings. This might help to identify bottlenecks which make the WL optimization run longer and such. One thing I've discovered, for instance, is that replacing built-in CrossOver()/CrossUnder() method calls with simple (value[bar-1<threshold) && (value[bar]>threshold) significantly improves script's performance.

I believe Visual Studio (full version, not Express) also has a built in profiler, but you have to pay for the VS license, of course.

I don't know if anybody had any experience with any other free .NET profiling tools. If yes, please share your thoughts here.
profile picture

Eugene

#2
Thank you for the information, good to know and really helpful.

QUOTE:
One thing I've discovered, for instance, is that replacing built-in CrossOver()/CrossUnder() method calls with simple (value[bar-1<threshold) && (value[bar]>threshold) significantly improves script's performance.

That's because CrossOver/CrossUnder also does some other internal check.
profile picture

avishn

#3
Yes, it seems CrossOver()/Under() jumps through a lot of hoops to provide accurate results for different (non-linear?) chart styles. For the simple linear OHLC or single-value type series most of the overhead can be eliminated by manually implementing the crossing rules.
profile picture

Eugene

#4
Starting from version 3.1, SharpDevelop also contains the Profiler tool, much more sophisticated than NProf. SharpDevelop is an alternative to Visual Studio Express, but it has some key features like attach-to-process (VS Express can also easily debug DLLs; the trick is thoroughly described in the Wiki KB article) and the Profiler.

From the Analysis menu, select Profiler and start Wealth-Lab the way NProf does it. (You can profile C# solutions as well.) Unlike NProf, there's an option to start collecting the profiling information on demand. I believe SD stores your profiling sessions in an SQLite database file for later review, but don't quote me on this.

After shutting WL5 down, you're presented with a window that has a Google Finance-like timeline at the top, two list views - Overview and Top 20, and a ring diagram. You can find a description of the tool below:

Introducing a New Tool in SharpDevelop – The Profiler
Pinpointing Interesting Methods
profile picture

avishn

#5
Thank you. It seems that SharpDevelop's profiler is definitely much more mature than NProf.
profile picture

Eugene

#6
Two more kids on the block:

SlimTune is a free profiler and performance analysis/tuning tool for .NET up to 4.0, x86/x64, open source

Prof-It for C#, seems to be inactive just like NProf
profile picture

Eugene

#7
Stumbled across this old thread. Visual Studio Community now has a profiler, too:

Visual Studio 2015 - Analyze Performance While Debugging in Visual Studio 2015