[Mono-dev] Patch for IPAddress.cs

Alan McGovern alan.mcgovern at gmail.com
Sat Mar 24 21:01:27 EDT 2007


I've attached my benchmarking code. Here are my benchmark results:

Method1 is the original method
Method2 is the original method changed to use | as opposed to +
Method3 is the new method

I ran the entire benchmark 15 times to give some accurate results.

mcs - 15 iterations
Method 1: 17641 ms
Method 2: 15810 ms
Method 3: 10750 ms


gmcs - 15 iteations
Method 1: 17608 ms
Method 2: 15782 ms
Method 3: 10578 ms


csc - 15 iterations
Method 1: 12999 ms
Method 2: 12157 ms
Method 3: 13109 ms

As you can see, csc creates faster code for method 1 and method 2 as
compared to mcs and gmcs. The difference between mcs and gmcs is negligible.
However (g)mcs creates faster code for method 3 than csc does.

However, as a comparison, the MS.NET implementation completes 15 loops of
the benchmark in a mere 6718ms ;)

Alan.



On 3/24/07, Gareth Pearce <tilps.kilm at gmail.com> wrote:
>
> Just wondering, did you compare combing the  byte parts with | instead
> of + to see if there was any performance difference?
>
> --Gareth
>
> Alan McGovern wrote:
> > With all the talk of BitConverting recently i took a look at
> > IPAddress.HostToNetwork(). I optimised the Swap*** methods to be a
> > little faster.
> >
> > My own tests show that the SwapLong method is approximately 35% faster
> > and the SwapInt method is approximately 25% faster. No NUnit tests are
> > needed as i didn't change any logic, i just removed the use of the
> > temporary variables.
> >
> > Alan.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070325/3f7a98f3/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bench.cs
Type: text/x-csharp
Size: 3607 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070325/3f7a98f3/attachment.bin 


More information about the Mono-devel-list mailing list