Humblecoder

Apprentice unit tester, expert rambler

Archive for the ‘CodePlex’ Category

I Was Wrong About Delegate Factories “Micro Optimisations”

without comments

In my previous post I talked about creating typed delegate factories, towards the end of the post I talked about optimising the performance by avoiding boxing when passing value type parameters around.  My premise was that if we could use generics to select strongly typed method signatures for the method that constructs the type we could avoid the boxing and unboxing of value types.  I think outside of dependencies, the most common constructor arguments is going to be value types.  But I was wrong.

Why?

It all boils down to Constructor.Invoke, this is the method my tiny dependency injection framework uses to create new instances of objects from the container.  Its only signature takes params object[] so all our hard work is useless because the values will be boxed for this call.

The biggest thing I was wrong about, though, was that reflection is quicker than boxing.  Lets look at the timing of the reflective generic approach:

reflective

So generating the factory takes 79ms when you reflect over the type and remove any generics.  But what about calling using params object[].

bloxing

This takes 31ms to create the factory.  So it is quite clear that, at least upfront, using the param approach is substantially quicker.  One thing I will point out is, the tests didn’t use the factories to create any types.  But the values will still be boxed when passed to the invoke method so I would still expect the second method to be more performant.

My point is that we need to look more closely at how we are going to use the code and if there is any optimisation, like caching the generated delegates, that would speed up calls after taking an initial hit.  If we didn’t need to make the call Constructor.Invoke would the second approach still be quicker overall in our application?

VN:F [1.9.3_1094]
Rating: 4.0/5 (2 votes cast)

Written by Will

February 13th, 2010 at 1:06 am

Posted in .NET, C#, CodePlex

Tagged with , , , ,

Why DirLinker Doesn’t Support XP

without comments

I posted up the Directory Linker CodePlex project a little over 2 weeks ago and it has clocked up a reasonable 103 downloads in that time.  Last night I was glancing over where the traffic came from on the stats page and a lot of referrals have come from this review site, they state that:

The app works on Windows 7 and Vista only, support for Windows XP is planned in the near future.

This is incorrect and maybe I should have been more clear that Directory Linker will not support XP unless there is some overwhelming outcry for it or someone else does it.

Why?

First for selfish reasons, I don’t use a machine that has XP installed anymore, furthermore, I would encourage anyone on XP to upgrade for security if nothing else.  At the end of the day, I created this tool for my use and I don’t use XP.

The second reason is technical, without going to far in, symbolic directory links have been in NTFS for quite a while but only got ‘first class’ support by the OS recently.  Previous to Vista they were called Junction Points and had all kinds of weird side effects (more details here).  Also, the API calls used by Directory Linker to create the symobolic link is only supported by Vista and above.  It is technically possible to do the same for XP and it is not difficult but Directory Linker simply doesn’t do it.

I hope that clears things up, also if you find a download link for Director Linker that links to SoftSea in anyway please do not use it.  If you’re not a programmer it’s safe to stop reading now.

Fork You!

Well, I rather you didn’t.  I will happily accept any patch that is submitted to the project to do this.  To help you out here is a quick overview on how to do  it.

  1. Locate FolderImp.cs and make the CreateLinkToFolderAt method virtual.
  2. Create a new class that inherits from FolderImp and name it to show it is for XP.
  3. Override only the CreateLinkToFolderAt and add the code to create a link in XP (Tip: start at DeviceIoControl).
  4. Open Program.cs and go to the FillIoCContainer method and add code to conditional select the correct IFolder class when the application starts.

Quite simple really.

VN:F [1.9.3_1094]
Rating: 3.0/5 (1 vote cast)

Written by Will

February 3rd, 2010 at 9:39 am

DirLinker: An Update

with one comment

 

In my previous post introducing DirLinker I posted up a short to do list and I can happily check off two of the shorter items.

  • Remove the dependency on Telerik and tidy up the UI –> Done, well it’s still not pretty but it doesn’t have a typo this time ;)
  • Post the source up on Codeplex –> http://dirlinker.codeplex.com/ 

Whether the rest will ever get done is another matter.  If you want to contribute then please go ahead.

VN:F [1.9.3_1094]
Rating: 0.0/5 (0 votes cast)

Written by Will

January 17th, 2010 at 12:41 pm

Posted in CodePlex, DirLinker

Get Adobe Flash playerPlugin by wpburn.com wordpress themes