Take the WF4 Speed Test

One of my previous posts talked about the performance improvements in WF4.  With the recent release of Visual Studio 2010 / .NET 4 RC1, I thought I would re-run my performance tests to see if there have been any further improvements with the most recent version.

My test is simply timing how long it takes to invoke an empty workflow (an Sequence activity that does nothing) 2,000,000 times.  This test gives us a good idea of the overhead of invoking a workflow.  With .NET 4.0 RC1, I am able to invoke ~275,000 workflows per second (approximately 15% faster than .NET 4 Beta 2).  I’m glad to see that Microsoft has continued to work on improving the performance of WF4. 

Take the WF4 speed test on your computer and let me know your results.  Create a new console application and past in the code below.  Don’t run the speed test in Visual Studio.  Compile the application and run the executable from outside Visual Studio.

using System;
using System.Linq;
using System.Activities;
using System.Activities.Statements;

namespace WFSpeedTest
class Program
static void Main(string[] args)
Activity activity = new Sequence();
WorkflowInvoker invoker = new WorkflowInvoker(activity);
DateTime startTime = DateTime.Now;
int numberOfInvokes = 2000000;
for (int i = 0; i < numberOfInvokes; i++)
DateTime endTime = DateTime.Now;
double workflowsPerSecond = numberOfInvokes / (endTime - startTime).TotalSeconds;
Console.WriteLine("Your WF Speed: {0} workflows per second", workflowsPerSecond);
Console.WriteLine("Press to exit…");

WF4 RC1, now 15% faster than WF4 Beta 2!