VB.NET... what are you doing?

by Moridin8 3. December 2009 13:45

Just a small post after a long time not posting (been moving between countries… it kinda takes up your spare time you know?)

 

Recently I have been working on a mostly VB.NET project in a more hands-on development capacity than I have been used to in recent years.  Needs must when you have a family to feed - especially in the current economy.

 

Whilst C# is by far my preferred language to work with (hence the name of this site) with Java and C++/CLI closely following, despite my general complaints, I have been using and retaining familiarity with VB.NET over the years as it’s always a good idea to ‘know your enemy’ so to speak.

 

There are many reasons I don’t like VB/BASIC as a language, but at least you would hope that no matter what, the VB.NET compiler team would at least do some basic optimisation on certain operations.  But it would seem that forcing integer division operations needlessly through the FPU is par for course…

 

This is a small peeve of mine… especially as it’s such an obvious and easy optimization.

 

In VB.NET, ‘CType’ is the quickest cast/conversion operation from a double to an Int32 in VB.NET the follow expression compiles to this (yes, all optimisations are ON):  [NB: ! prefix = unrequired)

 

! ldc.r8    100 // r8 = double ==> FPU (should be ldc.i4.s)

  ldarg.1

  callvirt  (blah..).get_Count()

! conv.r8   // r8 = double ==> FPU

  div

! call float64 (blah..).Math::Round(float64) // ==> JIT to FPU instructions

! conv.i4   // this will also be a couple of FPU instructions as return value is r8

  stloc.1

 

C# does *exactly* the same thing thus:

 

ldc.i4.s 100

ldarg.1

callvirt (blah..).get_Count()

div

stloc.1

 

Understandably the VB.NET version is ~2.2 times slower mostly due to needlessly forced FPU operations.

 

Funny, you would have thought this:

 

  DirectCast(100/distroItems.Count,Int32)

would be like:   (int)(100/distroItems.Count)

 

But the directcast operation is illegal...

 

Tags: , , ,

Articles | Blog

Reverseblade publishes my performance stats!

by Moridin8 17. June 2009 00:00

A while ago (with a little help) I threw together some performance stats for my employer.

Reverseblade (IRC.freenode.net / ##csharp) published them on his blog here.

Please post the usual complaints below  Wink

 

Tags: , , ,

Blog

Today I have been mostly...

by Moridin8 20. May 2009 16:48

... deploying BlogEngine.NET (your looking at it atm) and playing with some elements of the BlogEngine source code - Which whilst wonderfully functional - is somewhat lacking in quality. 

Cases in point: 

  • No unit tests....  (what? are we to just assume alterations to functionality just work?)
  • Isn't exactly optimized... (yes, with 10 minutes work, I already increased the speed of several areas by upto a factor of 3...)
  • Contains very little to no comments... or change history... (Who was that masked coder??)
  • the XML technology isn't well implemented... Big glaring example... schema anybody?
  • ....

Hey guys... how about a clean-up iteration or two?  Wink

Tags: , , , , , , ,

Blog

Powered by BlogEngine.NET 1.5.0.7

About Matt R.Warren

MeMy name is Matt and I am the current tenant of this small corner of the internet. I mostly architect, design and prototype applications that use .NET with C# and a little C++/CLI for Enterprise although I am aware of and enjoy fully embracing Java based solutions and alternatives such as Mono/Linux.  

I have worked on projects ranging from small tools to large distributed real-time Enterprise systems ranging from EPOS and real-time/JIT stock management systems, to distributed applications for National/International Utility, Healthcare, Insurance and Finance  in the private sector in both the USA and the EU.

My LinkedIn Profile (Opens new window/tab)

“Matt is one of the brightest people I've worked with. His in-depth knowledge of the .NET frameworks has been a tremendous benefit to nVISIA and our clients. His knowledge of software architecture in general allows him to architect systems for the best fit to his client's needs.” 
Dan Christopherson , Technical Director , nVISIA

“I had the distinct pleasure of working with Matt at nVisia. Matt's understanding of the Microsoft Technical space is outstanding. He is constantly working on improving his technical skills and rapidly masters any new technology that he encounters. He is an excellent teacher and a wonderful asset for any size team.” 
Jim Harnden , Senior Technical Architect , nVISIA

“Matt Warren is a very talented developer with great capacity for self study, investigation and adapts to new languages and frameworks with ease. He has an excellent grasp of software architecture and modern development principles. He has proven himself time and time again to be a hard worker and someone who can get the job done when you're in a tight spot.” 
Andrew Jump , Partner, C# Developer , Contegra

This website represents some of my spare time.  My small presence on the web between my family and my career.  I hope over time you find many useful things here.