Re: .net 2003 vs vc6 performance

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Crusader" <Crusader@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2B419AF5-CA4A-4828-B50B-0916E2685E54@xxxxxxxxxxxxxxxx
Hi Greg,

Well after your suggestions if i hv done following changes:
1. Turned off overflow checks
2. Build the app in Release mode.

After this code has been optimized a bit, but still there is a difference,
like VC6 code is executing in less than a second, nd the VB.Net code took
3
secs. Here is the VB.Net code for ur perusal:

Dim i As Long = 0, j As Long = 345678, mul As Long = 9876543
Dim iVar As Long
Console.WriteLine(Now)
For iVar = 0 To 10000000
i = (mul) * j ^ 1
Next
Console.WriteLine(Now)

I believe you'll find your answers are quite different between the managed
and unmanaged code. Moving to native C++ for the performance boost won't do
you any good if you break your code in the process.

Your VB.NET code is doing 64-bit multiplies. Since both factors are larger
than 32-bits, your result needs the 64-bit variable.
Your C code is only doing 32-bit multiplies. The answer will be wrong. The
64-bit type in MSVC is __int64, not long. However, instead of doing a
64-bit multiply, since both factors are under 32 bits, try the Win32 API
function Int32x32To64

It's no wonder the .NET code is running slower, and I'm surprised it's only
a factor of five slower. Different size multiply is a huge handicap.


Thnaks,

Crusader



"Greg Young" wrote:

You mention that you did this in VB.NET ... did you turn off the default
overflow checking? :)
http://addressof.com/blog/archive/2004/01/15/340.aspx

Also can you put up your VB.NET code in question? I would also imagine
there
may be a slight compilation difference in handling the long counter (as
opposed to an int counter which can easily be optimized to a register). I
believe most C++ compilers will pick this up but I don't remember if JIT
will pick it up.

The last question is did you run release mode code in Visual Studio? Even
with release mode code Visual Studio will by default disable JIT
optimizations.

Cheers,

Greg Young
MVP - C#
http://codebetter.com/blogs/gregyoung
"Crusader" <Crusader@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1E3DB259-D304-47A5-B15C-F887E82C6785@xxxxxxxxxxxxxxxx
Hi,
I m desperately looking for the performace difference between .Net 2003
and
VC6, so i just did following work:

Made a COM in VC++ which is executing following code:
STDMETHODIMP CNik_Loop::Calculate()
{
long i=0,j=345678,mul=9876543;
for(long a=0;a<10000000;a++)
{
i=(mul)*j^1;
}
return S_OK;
}

then i used this COM in .net, this function took juz 1 sec to execute.

After this i did same work in VB.Net 2003 and it took 5 secs.

Does this signifies tht unmanaged code is faster as compared to managed
.NET
code.
Please advise and comment.

Regards,
Crusader





.



Relevant Pages

  • Re: .net 2003 vs vc6 performance
    ... Turned off overflow checks ... opposed to an int counter which can easily be optimized to a register). ... optimizations. ... Made a COM in VC++ which is executing following code: ...
    (microsoft.public.dotnet.framework.performance)
  • Re: .net 2003 vs vc6 performance
    ... Turned off overflow checks ... The last question is did you run release mode code in Visual Studio? ... optimizations. ... Made a COM in VC++ which is executing following code: ...
    (microsoft.public.dotnet.framework.performance)
  • Re: [2.7 "thoughts"] V0.3
    ... > further abuse of the system unless the perpetrator was able to install and load ... and then use that program and an overflow sled to act as a poor-man's replacement ... exec-shield - We don't care if you're a trusted program, you're not executing off the stack. ...
    (Linux-Kernel)
  • [PATCH 2/7] s390: overflow in sched_clock.
    ... method multiplies first and then shifts the value to make the result ... with 1000 will overflow shortly after 52 days. ... by the scheduler for time stamp deltas, ... two time stamps the scheduler will get confused. ...
    (Linux-Kernel)
  • Re: DO loop standards question.
    ... Richard Maine wrote: ... >>What should the values of count and i be after executing this? ... >>2) There's an overflow so the behaviour is unspecified. ... for a 1 byte twos-complement i? ...
    (comp.lang.fortran)