Early Binding vs Late Binding

By | November 27, 2016

The Great Debate

A lot has been said and done about whether to use Early Binding or Late Binding in Dynamics CRM development. Everyone has undoubtedly read James Woods’ blogpost on this matter, and if you haven’t, you should!

This however was written about 3 years ago and I wanted to know if his findings are still valid. Therefore I did some performance tests with the new Dynamics 365 SDK (11/2016).

“Speed is a great asset; but it’s greater when it’s combined with quickness – and there’s a big difference.”
―Ty Cobb

As you know, speed is only half of the equation when it comes to the Early vs Late dilemma. But here I will focus purely on performance.

The tests

The following applies:

  • Dynamics 365 on premise environment (to rule out online latency)
  • 11 runs for each test of which the first will be discarded to have a ‘warm’ run (caching, reflection)
  • Creation of 25, 250 and 1000 records with 2 and 6 attributes
  • The Early and Late bound tests were ran in different tests to eliminate influence of the generated classes for early binding.
Early Binding vs Late binding

Creation of 25 records – Early Binding vs Late binding

Creation of 250 records - Early Binding vs Late Binding

Creation of 250 records – Early Binding vs Late Binding

Early Binding vs Late binding

Creation of 1000 records – Early Binding vs Late binding

 

The results

#Records Early 2 Early 6 Late 2 Late 6 Diff. 2 attrib Diff. 6 attrib
25 679,5 739,4 655,2 660,1111 24,3 79,28888889
250 5678,9 5743,4 5781,5 5884,7 -102,6 -141,3
1000 22984,6 23219,1 22948,3 23659,9 36,3 -440,8

Beforehand I was convinced that one would surpass the other in speed at a certain amount of records but apparently there is no real correlation between this. But in general the results are not that different. 440 milliseconds on 1000 records is not very much.

Purely based on speed I can’t tell you what to use. I would suggest to set up some tests when you have >1M records to process and then you’ll definitely benefit from your test results.
But then again if you are processing >1M records maybe you should look into other methods than a .NET console application.

Leave a Reply

Your email address will not be published. Required fields are marked *