Click here to Skip to main content
15,350,008 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralIt sucks to be a Canadian skier in 2012... Pin
Maximilien10-Mar-12 6:06
MemberMaximilien10-Mar-12 6:06 
GeneralRe: It sucks to be a Canadian skier in 2012... Pin
NetDave10-Mar-12 7:32
MemberNetDave10-Mar-12 7:32 
GeneralRe: It sucks to be a Canadian skier in 2012... Pin
AspDotNetDev10-Mar-12 12:24
protectorAspDotNetDev10-Mar-12 12:24 
GeneralRe: It sucks to be a Canadian skier in 2012... Pin
Maximilien10-Mar-12 12:42
MemberMaximilien10-Mar-12 12:42 
JokeBreakfast to go Pin
Ravi Bhavnani10-Mar-12 4:45
professionalRavi Bhavnani10-Mar-12 4:45 
GeneralFun performance test on Win7/Win8 with C++, C#(3.5,4,4.5) and Math.Sqrt() as special guest Pin
Super Lloyd10-Mar-12 4:30
MemberSuper Lloyd10-Mar-12 4:30 
GeneralRe: Fun performance test on Win7/Win8 with C++, C#(3.5,4,4.5) and Math.Sqrt() as special guest Pin
harold aptroot10-Mar-12 4:34
Memberharold aptroot10-Mar-12 4:34 
GeneralRe: Fun performance test on Win7/Win8 with C++, C#(3.5,4,4.5) and Math.Sqrt() as special guest Pin
Super Lloyd10-Mar-12 4:54
MemberSuper Lloyd10-Mar-12 4:54 
It might be quite verbose.... let's just pick a few

TC++
ASM
__declspec(noinline) double fct(int i, int j)
{
01301000  push        ebp  
01301001  mov         ebp,esp  
	return sqrt((double)i);
01301003  fild        dword ptr [i]  
}
01301006  pop         ebp  
	return sqrt((double)i);
01301007  jmp         _CIsqrt (13019B0h)  
--- No source file -------------------------------------------------------------
0130100C  int         3  
0130100D  int         3  
0130100E  int         3  
0130100F  int         3  
--- c:\dev\test\perfdouble\pdouble\pdouble.cpp ---------------------------------

int primes(unsigned long n) {
01301010  push        ebp  
01301011  mov         ebp,esp  
01301013  sub         esp,8  
01301016  push        esi  
01301017  push        edi  
unsigned long i, j;
int countprimes = 0;
  for(i = 1; i <= n; i++) {
01301018  mov         edi,1  
0130101D  cmp         ebx,edi  
0130101F  jb          primes+55h (1301065h)  
      int isprime = 1;
	  float limit = sqrt((double)i);
      for(j = 2; j < fct(i, j); j++) 
01301021  push        edi  
01301022  mov         esi,2  
01301027  call        fct (1301000h)  
0130102C  fcom        qword ptr [__real@4000000000000000 (1302120h)]  
01301032  add         esp,4  
01301035  fnstsw      ax  
01301037  test        ah,41h  
0130103A  jne         primes+4Eh (130105Eh)  
          if(!(i%j)) {
0130103C  xor         edx,edx  
0130103E  mov         eax,edi  
01301040  div         eax,esi  
01301042  test        edx,edx  
01301044  je          primes+4Eh (130105Eh)  
      int isprime = 1;
	  float limit = sqrt((double)i);
      for(j = 2; j < fct(i, j); j++) 
01301046  inc         esi  
01301047  mov         dword ptr [ebp-4],esi  
0130104A  fild        dword ptr [ebp-4]  
0130104D  jns         primes+45h (1301055h)  
0130104F  fadd        qword ptr [__real@41f0000000000000 (1302118h)]  
01301055  fcomp       st(1)  
01301057  fnstsw      ax  
01301059  test        ah,5  
0130105C  jnp         primes+2Ch (130103Ch)  
unsigned long i, j;
int countprimes = 0;
  for(i = 1; i <= n; i++) {
0130105E  inc         edi  
      int isprime = 1;
	  float limit = sqrt((double)i);
      for(j = 2; j < fct(i, j); j++) 
0130105F  fstp        st(0)  
01301061  cmp         edi,ebx  
01301063  jbe         primes+11h (1301021h)  
        isprime = 0;
        break;
   }
    countprimes+= isprime;
  }
  throw "break here";
01301065  push        offset __TI2PAD (13022F8h)  
0130106A  lea         ecx,[ebp-4]  
0130106D  push        ecx  
0130106E  mov         dword ptr [ebp-4],offset string "break here" (130210Ch)  
01301075  call        _CxxThrowException (13019B6h)  
$LN23:
0130107A  int         3  
--- No source file -------------------------------------------------------------
0130107B  int         3  
0130107C  int         3  
0130107D  int         3  
0130107E  int         3  
0130107F  int         3  
--- c:\dev\test\perfdouble\pdouble\pdouble.cpp ---------------------------------
  return countprimes;
}


did the disassembly for the slow version (TC#1)

TC#1, .NET4, win7
ASM
00000000  push        ebp 
00000001  mov         ebp,esp 
00000003  push        edi 
00000004  push        esi 
00000005  sub         esp,0Ch 
00000008  mov         dword ptr [ebp-0Ch],ecx 
0000000b  mov         esi,1 
00000010  mov         eax,dword ptr [ebp-0Ch] 
00000013  cdq 
00000014  test        edx,edx 
00000016  jg          0000001F 
00000018  jl          0000007B 
0000001a  cmp         eax,1 
0000001d  jb          0000007B 
0000001f  mov         edi,1 
00000024  lea         ecx,[edi+1] 
00000027  jmp         00000038 
00000029  mov         eax,esi 
0000002b  xor         edx,edx 
0000002d  div         eax,ecx 
0000002f  test        edx,edx 
00000031  jne         00000037 
00000033  xor         edi,edi 
00000035  jmp         00000062 
00000037  inc         ecx 
00000038  xor         eax,eax 
0000003a  mov         dword ptr [ebp-14h],esi 
0000003d  mov         dword ptr [ebp-10h],eax 
00000040  fild        qword ptr [ebp-14h] 
00000043  fstp        qword ptr [ebp-14h] 
00000046  fld         qword ptr [ebp-14h] 
00000049  fsqrt 
0000004b  mov         dword ptr [ebp-14h],ecx 
0000004e  mov         dword ptr [ebp-10h],eax 
00000051  fild        qword ptr [ebp-14h] 
00000054  fstp        qword ptr [ebp-14h] 
00000057  fld         qword ptr [ebp-14h] 
0000005a  fcomip      st,st(1) 
0000005c  fstp        st(0) 
0000005e  jp          00000062 
00000060  jbe         00000029 
00000062  test        edi,edi 
00000064  je          00000066 
00000066  inc         esi 
00000067  xor         eax,eax 
00000069  mov         edx,dword ptr [ebp-0Ch] 
0000006c  mov         ecx,edx 
0000006e  sar         ecx,1Fh 
00000071  cmp         eax,ecx 
00000073  jg          0000007B 
00000075  jl          0000001F 
00000077  cmp         esi,edx 
00000079  jbe         0000001F 
0000007b  mov         ecx,60BDFC48h 
00000080  call        FFEB1E10 
00000085  mov         esi,eax 
00000087  mov         edx,182EA4h 
0000008c  mov         ecx,70000001h 
00000091  call        61524745 
00000096  mov         edx,eax 
00000098  mov         ecx,esi 
0000009a  call        60E023E0 
0000009f  mov         ecx,esi 
000000a1  call        61521086 
000000a6  int         3 


TC#1, .NET3.5, win7
ASM
00000000  push        ebp 
00000001  mov         ebp,esp 
00000003  push        edi 
00000004  push        esi 
00000005  sub         esp,0Ch 
00000008  mov         dword ptr [ebp-0Ch],ecx 
0000000b  mov         esi,1 
00000010  mov         eax,dword ptr [ebp-0Ch] 
00000013  cdq 
00000014  test        edx,edx 
00000016  jg          0000001F 
00000018  jl          0000007B 
0000001a  cmp         eax,1 
0000001d  jb          0000007B 
0000001f  mov         edi,1 
00000024  lea         ecx,[edi+1] 
00000027  jmp         00000038 
00000029  mov         eax,esi 
0000002b  xor         edx,edx 
0000002d  div         eax,ecx 
0000002f  test        edx,edx 
00000031  jne         00000037 
00000033  xor         edi,edi 
00000035  jmp         00000062 
00000037  inc         ecx 
00000038  xor         eax,eax 
0000003a  mov         dword ptr [ebp-14h],esi 
0000003d  mov         dword ptr [ebp-10h],eax 
00000040  fild        qword ptr [ebp-14h] 
00000043  fstp        qword ptr [ebp-14h] 
00000046  fld         qword ptr [ebp-14h] 
00000049  fsqrt 
0000004b  mov         dword ptr [ebp-14h],ecx 
0000004e  mov         dword ptr [ebp-10h],eax 
00000051  fild        qword ptr [ebp-14h] 
00000054  fstp        qword ptr [ebp-14h] 
00000057  fld         qword ptr [ebp-14h] 
0000005a  fcomip      st,st(1) 
0000005c  fstp        st(0) 
0000005e  jp          00000062 
00000060  jbe         00000029 
00000062  test        edi,edi 
00000064  je          00000066 
00000066  inc         esi 
00000067  xor         eax,eax 
00000069  mov         edx,dword ptr [ebp-0Ch] 
0000006c  mov         ecx,edx 
0000006e  sar         ecx,1Fh 
00000071  cmp         eax,ecx 
00000073  jg          0000007B 
00000075  jl          0000001F 
00000077  cmp         esi,edx 
00000079  jbe         0000001F 
0000007b  mov         ecx,66CA0D04h 
00000080  call        FFE41E4C 
00000085  mov         esi,eax 
00000087  mov         edx,292F2Ch 
0000008c  mov         ecx,70000001h 
00000091  call        671A9052 
00000096  mov         edx,eax 
00000098  mov         ecx,esi 
0000009a  call        6681A7A0 
0000009f  mov         ecx,esi 
000000a1  call        671A9187 
000000a6  int         3 


TC1, .NET4, win8
ASM
00000000  push        rbx 
00000001  push        rdi 
00000002  sub         rsp,28h 
00000006  movsxd      r8,ecx 
00000009  cmp         r8,1 
0000000d  jl          0000000000000080 
0000000f  mov         ecx,1 
00000014  nop         word ptr [rax+rax+00000000h] 
00000020  mov         eax,ecx 
00000022  cvtsi2sd    xmm0,rax 
00000027  mov         eax,2 
0000002c  mov         eax,eax 
0000002e  cvtsi2sd    xmm1,rax 
00000033  sqrtsd      xmm0,xmm0 
00000037  ucomisd     xmm0,xmm1 
0000003b  jb          000000000000006A 
0000003d  mov         r9d,2 
00000043  xor         edx,edx 
00000045  mov         eax,ecx 
00000047  div         eax,r9d 
0000004a  test        edx,edx 
0000004c  je          000000000000006A 
0000004e  inc         r9d 
00000051  mov         eax,r9d 
00000054  cvtsi2sd    xmm2,rax 
00000059  mov         eax,ecx 
0000005b  cvtsi2sd    xmm0,rax 
00000060  sqrtsd      xmm1,xmm0 
00000064  ucomisd     xmm1,xmm2 
00000068  jae         0000000000000043 
0000006a  inc         ecx 
0000006c  mov         eax,ecx 
0000006e  cmp         rax,r8 
00000071  jle         0000000000000020 
00000073  jmp         0000000000000080 
00000075  add         rsp,28h 
00000079  pop         rdi 
0000007a  pop         rbx 
0000007b  ret 
0000007c  nop         dword ptr [rax] 
00000080  lea         rdx,[FFEE2D70h] 
00000087  mov         ecx,70000001h 
0000008c  call        000000005F7A0A70 
00000091  mov         rbx,rax 
00000094  lea         rcx,[5E8109F0h] 
0000009b  call        000000005F682310 
000000a0  mov         rdi,rax 
000000a3  mov         rdx,rbx 
000000a6  mov         rcx,rdi 
000000a9  call        000000005ED99BC0 
000000ae  mov         rcx,rdi 
000000b1  call        000000005F79EF24 
000000b6  nop 

A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.

GeneralRe: Fun performance test on Win7/Win8 with C++, C#(3.5,4,4.5) and Math.Sqrt() as special guest Pin
harold aptroot10-Mar-12 5:02
Memberharold aptroot10-Mar-12 5:02 
GeneralRe: Fun performance test on Win7/Win8 with C++, C#(3.5,4,4.5) and Math.Sqrt() as special guest Pin
Super Lloyd10-Mar-12 5:09
MemberSuper Lloyd10-Mar-12 5:09 
GeneralRe: Fun performance test on Win7/Win8 with C++, C#(3.5,4,4.5) and Math.Sqrt() as special guest Pin
Super Lloyd10-Mar-12 5:00
MemberSuper Lloyd10-Mar-12 5:00 
GeneralRe: Fun performance test on Win7/Win8 with C++, C#(3.5,4,4.5) and Math.Sqrt() as special guest Pin
#realJSOP10-Mar-12 5:52
mva#realJSOP10-Mar-12 5:52 
GeneralRe: Fun performance test on Win7/Win8 with C++, C#(3.5,4,4.5) and Math.Sqrt() as special guest Pin
Super Lloyd10-Mar-12 13:16
MemberSuper Lloyd10-Mar-12 13:16 
GeneralRe: Fun performance test on Win7/Win8 with C++, C#(3.5,4,4.5) and Math.Sqrt() as special guest Pin
NormDroid10-Mar-12 6:35
professionalNormDroid10-Mar-12 6:35 
GeneralRe: Fun performance test on Win7/Win8 with C++, C#(3.5,4,4.5) and Math.Sqrt() as special guest Pin
harold aptroot10-Mar-12 6:42
Memberharold aptroot10-Mar-12 6:42 
GeneralBackwards flying space shuttle... Pin
Sander Rossel10-Mar-12 0:27
professionalSander Rossel10-Mar-12 0:27 
GeneralRe: Backwards flying space shuttle... Pin
Nelek10-Mar-12 1:13
protectorNelek10-Mar-12 1:13 
GeneralIt's official: the end of the world is tomorrow. Pin
Septimus Hedgehog9-Mar-12 22:39
MemberSeptimus Hedgehog9-Mar-12 22:39 
GeneralRe: It's official: the end of the world is tomorrow. Pin
Richard MacCutchan9-Mar-12 22:40
mveRichard MacCutchan9-Mar-12 22:40 
GeneralRe: It's official: the end of the world is tomorrow. Pin
User 592419-Mar-12 23:00
MemberUser 592419-Mar-12 23:00 
GeneralRe: It's official: the end of the world is tomorrow. Pin
Dalek Dave9-Mar-12 23:11
professionalDalek Dave9-Mar-12 23:11 
GeneralRe: It's official: the end of the world is tomorrow. Pin
chriselst9-Mar-12 23:26
Memberchriselst9-Mar-12 23:26 
GeneralRe: It's official: the end of the world is tomorrow. Pin
Super Lloyd9-Mar-12 23:53
MemberSuper Lloyd9-Mar-12 23:53 
GeneralRe: It's official: the end of the world is tomorrow. Pin
User 5924110-Mar-12 0:14
MemberUser 5924110-Mar-12 0:14 
GeneralRe: It's official: the end of the world is tomorrow. Pin
OriginalGriff10-Mar-12 0:27
mveOriginalGriff10-Mar-12 0:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

What language are you using for AI development or learning?
Whether you're at work or home, hard core coding or just trying to figure out this AI thing, which languages have you used in your adventures?
  Results   290 votes