by Mathias
13. June 2010 12:30
In my last post I explored how ExcelDNA can be used to write high-performance UDFs for Excel, calling .Net code without the overhead of VSTO. Using .Net instead of VBA for intensive computations already yields a nice improvement. Still, I regretted that ExcelDNA supports .Net up to 3.5 only, which puts the Task Parallel Library off limits – and is too bad because the TPL is just totally awesome to leverage the power of multi-cores.
As it turned out, this isn’t totally correct. Govert Van Drimmelen (the man behind ExcelDNA) and Jon Skeet (the Chuck Norris of .Net) pointed that while the Task Parallel Library is a .Net 4.0 library, the Reactive Extensions for .Net 3.5 contains an unsupported 3.5 version of the TPL – which means that it should be possible to get parallelism to work with ExcelDNA.
This isn’t a pressing need of mine, so I thought I would leave that alone, and wait for the 4.0 version of ExcelDNA. Yeah right. Between my natural curiosity, Ross McLean’s comment (have fun at the Excel UK Dev Conference!), and the fact that I really want to know if I could get the Walkenbach test to run under 1 second, without too much of an effort, I had to check. And the good news is, yep, it works.
Last time we saw how to turn an average PC into a top-notch performer; let’s see how we can inject some parallelism to get a smoking hot calculation engine.
More...
b3fd321f-a45e-4314-8839-dbd9b8d1a713|1|5.0
by Mathias
7. June 2010 10:23
Some time ago, I came across ExcelDNA, an open-source library designed to integrate .Net into Excel, via a post by the Grumpy One, who described it as an interesting way to get Excel to talk to a compiled library. Sounds right down my alley, but I still managed to let 6 months pass until I finally tried it.
This reminded me of another post, by J-Walk this time, where he uses a random walk simulation in VBA to benchmark system performance. Back then, I ran the VBA code, and also the equivalent C# in a console app, out of curiosity: 11.38 seconds, vs. 2.73 seconds. Why not try the same experiment, and see if we can get the best of both worlds and bring some of the C# power into Excel via ExcelDNA?
So I created a Class Library, with the following method, a close equivalent to the VBA benchmark code:
public class Experiment
{
public static string RandomWalk()
{
var stopwatch = new Stopwatch();
stopwatch.Start();
var position = 0;
var random = new Random();
for (var run = 0; run < 100000000; run++)
{
if (random.Next(0, 2) == 0)
{
position++;
}
else
{
position--;
}
}
stopwatch.Stop();
var elapsed = (double)stopwatch.ElapsedMilliseconds / 1000d;
return "Position: " + position.ToString() + ", Time: " + elapsed.ToString();
}
}
More...
8379a752-d43e-4d85-838c-47a5e2642203|2|5.0
by Mathias
4. June 2010 12:19
I am very honored that the East Bay chapter of the Bay Area .Net user group will have me as a speaker this upcoming Wednesday. I’ll be talking “For Those About to Mock”, about Mocks and Stubs in .Net, after a presentation of the unit testing features of Visual Studio by Deborah Kurata – an apt opening topic, if you ask me.
You can find more information about this event here; Hope to see you on Wednesday!
c1a10f79-2ad5-48ed-a3da-7cd227f9e65f|0|.0
by Mathias
26. May 2010 06:55
I finally got to reviewing and scrubbing the code for the part 2 of my Excel 2007 VSTO tutorial; you can download the code here. Next chapter, we will venture into the joys of deployment.
In the meanwhile, please feel free to let me know in the comments what you think, like and dislike, and how I can make this better!
bc9b7194-2bf9-4bc8-afa4-85d0edbb0f79|0|.0
by Mathias
20. May 2010 06:43
I gave a quick Firestarter talk at the San Francisco .Net user group yesterday about .less. .less (‘dot-less’) is an open source .Net library, which extends the functionality of CSS (it works with your existing CSS files), adding features like variables, using a syntax close to CSS. If you find that working with CSS causes some teeth-grinding , you should probably have a look!
Download the slide deck here
fd0d38d2-4317-4734-bb51-e2da292d96e0|0|.0