Home > Software engineering >  VS2005 compiled VS2015 program execution speed of the problem?
VS2005 compiled VS2015 program execution speed of the problem?

Time:10-14

Program the following
 DWORD begintick; 
DWORD len.
Begintick=: : GetTickCount ();
Char * p;
for(i=0; i<40000000; I++)
{int ik.
P=new char [2000].
For (ik=0; Ik<2000; Ik++)
P=ik (ik);
The delete p;
}

Len=: : GetTickCount () - begintick;
Printf (" the len=% d ", len);


Use 64 - bit program RELEASE (32-bit) don't try on the same machine running, the results of two difference between the speed of over 10%, didn't think there will be such a difference, or some other problem, about the compiler Settings I probably check once, no problem,

CodePudding user response:

Disassembling the found a use INC a use the ADD 1 instruction is for this reason, after testing, the p=ik (ik); To p (ik)=8; After the speed and basically consistent,

CodePudding user response:

The delete [] p;

This is better,

CodePudding user response:

The delete [] p; The delete p; Effect is the same, p refers not to the object,
I pay attention to the problem of the optimal effect of the two compilers,

CodePudding user response:

Relating to the new, related to system of library, if you compare the optimization effect, the assembly code,

CodePudding user response:

Found out, may be NEW to DELETE efficiency, VS2005 NEW performs slower,

CodePudding user response:

Windows 7 XP for Muslim alienation, actually VC8 is a Dutch edition, while the burst of the Netherlands is chaotic, but the Dutch or a member of the allied,
To understand this, why Windows 7 programs compiled VC8 slow reason is simple,

CodePudding user response:

Don't talk about efficiency without profiler!! Especially in the cloud computing, virtual machine, simulator, CUDA, multi-core, multistage cache, command line, a variety of storage media,... In the age of flying!

CodePudding user response:

I found both checked the compiler still has certain difference on performance, to NEW DELETE
Procedure is as follows:
DWORD I;
DWORD begintick;
DWORD len.
Char * p; P=new char [2000]. Begintick=: : GetTickCount ();
for (i=0; i<40000000; I++)
{
Int ik.
For (ik=0; Ik<2000; Ik++)
{
P=ik (ik);
}

}
Len=: : GetTickCount () - begintick;
The delete p;
Printf (" the len=% d ", len);

VS2015 compile the following

For (ik=0; Ik<2000; Ik++)
000000013 fe11040 xor ecx, ecx
000000013 fe11042 mov RDX, RBX
000000013 fe11045 nop word PTR [+ rax rax]
{
P=ik (ik);
000000013 fe11050 mov byte PTR (RDX), cl
000000013 fe11052 lea RDX, RDX + 1
000000013 fe11056 inc ecx
000000013 fe11058 CMP ecx, 7 d0h
000000013 fe1105e jl main + 50 h (013 fe11050h)
for (i=0; i<40000000; I++)
000000013 fe11060 sub r8, 1
000000013 fe11064 developed main + 40 h (013 fe11040h)

}

VS2005 compiled the following
For (ik=0; Ik<2000; Ik++)
0000000000401030 xor ecx, ecx
0000000000401032 mov RDX, RBX
0000000000401035 XCHG ax, ax
0000000000401039 XCHG ax, ax
000000000040103 c XCHG ax, ax
{
P=ik (ik);
0000000000401040 mov byte PTR (RDX), cl
0000000000401042 add ecx, 1
0000000000401045 add RDX, 1
0000000000401049 CMP ecx, 7 d0h
000000000040104 f jl wmain + 40 h (401040 h)
for (i=0; i<40000000; I++)
0000000000401051 sub r8, 1
0000000000401055 developed wmain + 30 h (401030 h)

}


Execution speed difference in 10%,

Even more unexpected is that if change p=ik (ik); For p=8 (ik)
VS2015 shows execution is 0, the disassembly and no corresponding code, namely as the compiler knows this code was invalid code,
But there is no the optimization results, VS2005

CodePudding user response:

So, let's try with the latest compilers
  • Related