Tag Archives: performance
New Json.NET is here – smaller and faster
Published on January 4th, 2010.
The latest release of Json.NET has a lot of improvements which make it preferable to other techniques. The team has done really a great job to increase the speed of both serialization and deserialization.
Json.NET is faster than both the JavaScriptSerializer and the WCF DataContractJsonSerializer over all scenarios. It reached the level of the XML based DataContractSerializer which is pretty remarkable. Json.NET over binary (BSON) is considerably faster than the .NET BinaryFormatter, too. Another one of the benefits of JSON is its smaller size when compared to equivalent XML. The output of Json.NET is less than half the size of the XML that DataContractSerializer produces. Read more about these tests on James Newton’s post.
Download the latest release of Json.NET and try it yourself!
Filled under .NET, C#, News. No Comments.
Arranging Numbers at Random
Published on February 2nd, 2008.
Let’s say we want to arrange the numbers from 1 to 100 at random. This is a little confusing problem but there is a solution (not only one) for it. The basic way is the following: you have an array where you put your numbers, you generate a random number while this number is not contained in your array, then you add it to the array. Well, this method is very sluggish! When you add numbers to the array you decrease the size of the multitude of possible numbers. And when this size is too little, the while cycle loops very long until you get a random number, which is not already added to the array. Here is this example. I have used a stopwatch to count the necessary time for this method to finish. (more…)
Filled under C#. No Comments.