21,595
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include<sys/time.h>
#define ppp_hong(n) ((n)*(n))
extern int ppp(int n);
extern inline int ppp_inline(int n);
int
main(int argc, char *argv[])
{
unsigned run1,run2,run3;
struct timeval start,end,ss,ee;
gettimeofday(&start,NULL);
for(int i=0; i<10; )
{
printf("use ppp_hong :the square of %d is %d \n",i, ppp_inline(i));
i++;
}
gettimeofday(&end,NULL);
run1 = 1000000*(end.tv_sec-start.tv_sec)+end.tv_usec-start.\
tv_usec;
printf("the inline has runned %d \n",run1);
gettimeofday(&ss,NULL);
for(int ii=0; ii<10; )
{
printf("the square of %d is %d \n",ii, ppp(ii));
ii++;
}
gettimeofday(&ee,NULL);
run2 = 1000000*(ee.tv_sec-ss.tv_sec)+ee.tv_usec-ss.\
tv_usec;
printf("the inline has runned %d \n",run2);
printf("the diff is :\n");
printf("\t\tthe inline 's usec is %d \n",run1);
printf("\t\tthe stock 's usec is %d \n",run2);
return 1;
}
.text:08048424 public ppp
.text:08048424 ppp proc near ; CODE XREF: main+B0p
.text:08048424
.text:08048424 arg_0 = dword ptr 8
.text:08048424
.text:08048424 push ebp
.text:08048425 mov ebp, esp
.text:08048427 mov eax, [ebp+arg_0]
.text:0804842A imul eax, [ebp+arg_0]
.text:0804842E pop ebp
.text:0804842F retn
.text:0804842F ppp endp
.text:0804842F
.text:08048430
.text:08048430 ; 圹圹圹圹圹圹圹?S U B R O U T I N E 圹圹圹圹圹圹圹圹圹圹圹圹圹圹圹圹圹圹圹?
.text:08048430
.text:08048430 ; Attributes: bp-based frame
.text:08048430
.text:08048430 public ppp_inline
.text:08048430 ppp_inline proc near ; CODE XREF: main+33p
.text:08048430
.text:08048430 arg_0 = dword ptr 8
.text:08048430
.text:08048430 push ebp
.text:08048431 mov ebp, esp
.text:08048433 mov eax, [ebp+arg_0]
.text:08048436 imul eax, [ebp+arg_0]
.text:0804843A pop ebp
.text:0804843B retn
.text:0804843B ppp_inline endp
.text:0804843B
.text:0804843C
.text:0804843C ; 圹圹圹圹圹圹圹?S U B R O U T I N E 圹圹圹圹圹圹圹圹圹圹圹圹圹圹圹圹圹圹圹?
.text:0804843C
.text:0804843C ; Attributes: bp-based frame
.text:0804843C
.text:0804843C public main
.text:0804843C main proc near ; DATA XREF: _start+17o
.text:0804843C
.text:0804843C var_60 = dword ptr -60h
.text:0804843C var_5C = dword ptr -5Ch
.text:0804843C var_38 = dword ptr -38h
.text:0804843C var_34 = dword ptr -34h
.text:0804843C var_30 = dword ptr -30h
.text:0804843C var_2C = dword ptr -2Ch
.text:0804843C var_28 = dword ptr -28h
.text:0804843C var_24 = dword ptr -24h
.text:0804843C var_20 = dword ptr -20h
.text:0804843C var_1C = dword ptr -1Ch
.text:0804843C var_18 = dword ptr -18h
.text:0804843C var_14 = dword ptr -14h
.text:0804843C var_C = dword ptr -0Ch
.text:0804843C var_8 = dword ptr -8
.text:0804843C arg_0 = dword ptr 4
.text:0804843C
.text:0804843C lea ecx, [esp+arg_0]
.text:08048440 and esp, 0FFFFFFF0h
.text:08048443 push dword ptr [ecx-4]
.text:08048446 push ebp
.text:08048447 mov ebp, esp
.text:08048449 push ecx
.text:0804844A sub esp, 54h ; char *
.text:0804844D mov [esp+60h+var_5C], 0
.text:08048455 lea eax, [ebp+var_20]
.text:08048458 mov [esp+60h+var_60], eax
.text:0804845B call _gettimeofday
.text:08048460 mov [ebp+var_C], 0
.text:08048467 jmp short loc_8048478
.text:08048469 ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
.text:08048469
.text:08048469 loc_8048469: ; CODE XREF: main+43j
.text:08048469 mov eax, [ebp+var_C]
.text:0804846C mov [esp+60h+var_60], eax
.text:0804846F call ppp_inline
.text:08048474 add [ebp+var_C], 1
.text:08048478
.text:08048478 loc_8048478: ; CODE XREF: main+2Bj
.text:08048478 cmp [ebp+var_C], 0F423Fh
.text:0804847F jle short loc_8048469
.text:08048481 mov [esp+60h+var_5C], 0
.text:08048489 lea eax, [ebp+var_28]
.text:0804848C mov [esp+60h+var_60], eax
.text:0804848F call _gettimeofday
.text:08048494 mov edx, [ebp+var_28]
.text:08048497 mov eax, [ebp+var_20]
.text:0804849A mov ecx, edx
.text:0804849C sub ecx, eax
.text:0804849E mov eax, ecx
.text:080484A0 imul edx, eax, 0F4240h
.text:080484A6 mov eax, [ebp+var_24]
.text:080484A9 add edx, eax
.text:080484AB mov eax, [ebp+var_1C]
.text:080484AE mov ecx, edx
.text:080484B0 sub ecx, eax
.text:080484B2 mov eax, ecx
.text:080484B4 mov [ebp+var_18], eax
.text:080484B7 mov eax, [ebp+var_18]
.text:080484BA mov [esp+60h+var_5C], eax
.text:080484BE mov [esp+60h+var_60], offset aTheInlineHasRu ; "the inline has runned %d \n"
.text:080484C5 call _printf
.text:080484CA mov [esp+60h+var_5C], 0
.text:080484D2 lea eax, [ebp+var_30]
.text:080484D5 mov [esp+60h+var_60], eax
.text:080484D8 call _gettimeofday
.text:080484DD mov [ebp+var_8], 0
.text:080484E4 jmp short loc_80484F5
.text:080484E6 ; 哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪哪?
.text:080484E6
.text:080484E6 loc_80484E6: ; CODE XREF: main+C0j
.text:080484E6 mov eax, [ebp+var_8]
.text:080484E9 mov [esp+60h+var_60], eax
.text:080484EC call ppp
.text:080484F1 add [ebp+var_8], 1
.text:080484F5
.text:080484F5 loc_80484F5: ; CODE XREF: main+A8j
.text:080484F5 cmp [ebp+var_8], 0F423Fh
.text:080484FC jle short loc_80484E6
.text:080484FE mov [esp+60h+var_5C], 0
.text:08048506 lea eax, [ebp+var_38]
.text:08048509 mov [esp+60h+var_60], eax
.text:0804850C call _gettimeofday
.text:08048511 mov edx, [ebp+var_38]
.text:08048514 mov eax, [ebp+var_30]
.text:08048517 mov ecx, edx
.text:08048519 sub ecx, eax
.text:0804851B mov eax, ecx
.text:0804851D imul edx, eax, 0F4240h
.text:08048523 mov eax, [ebp+var_34]
.text:08048526 add edx, eax
.text:08048528 mov eax, [ebp+var_2C]
.text:0804852B mov ecx, edx
.text:0804852D sub ecx, eax
.text:0804852F mov eax, ecx
.text:08048531 mov [ebp+var_14], eax
.text:08048534 mov eax, [ebp+var_14]
.text:08048537 mov [esp+60h+var_5C], eax
.text:0804853B mov [esp+60h+var_60], offset aTheInlineHasRu ; "the inline has runned %d \n"
.text:08048542 call _printf
#include<sys/time.h>
int ppp(int n)
{
return ((n)*(n));
}
inline int ppp_inline(int n)
{
return ((n)*(n));
}
void XXXXXXX::run()
{
unsigned run1,run2,run3;
struct timeval start,end,ss,ee;
gettimeofday(&start,NULL);
for(int i=0; i<10000; )//这里
{
ppp_inline(i);//这里
i++;
}
gettimeofday(&end,NULL);
run1 = 1000000*(end.tv_sec-start.tv_sec)+end.tv_usec-start.\
tv_usec;
printf("the inline has runned %d \n",run1);
gettimeofday(&ss,NULL);
for(int ii=0; ii<10000; )//这里
{
ppp(ii);//这里
ii++;
}
gettimeofday(&ee,NULL);
run2 = 1000000*(ee.tv_sec-ss.tv_sec)+ee.tv_usec-ss.\
tv_usec;
printf("the inline has runned %d \n",run2);
printf("the diff is :\n");
printf("\t\tthe inline 's usec is %d \n",run1);
printf("\t\tthe stock 's usec is %d \n",run2);
}
int
main(int argc, char *argv[])
{
unsigned run1,run2,run3;
struct timeval start,end,ss,ee;
gettimeofday(&start,NULL);
for(int i=0; i<10000; )//这里
{
ppp_inline(i);//这里
i++;
}
gettimeofday(&end,NULL);
run1 = 1000000*(end.tv_sec-start.tv_sec)+end.tv_usec-start.\
tv_usec;
printf("the inline has runned %d \n",run1);
gettimeofday(&ss,NULL);
for(int ii=0; ii<10000; )//这里
{
ppp(ii);//这里
ii++;
}
gettimeofday(&ee,NULL);
run2 = 1000000*(ee.tv_sec-ss.tv_sec)+ee.tv_usec-ss.\
tv_usec;
printf("the inline has runned %d \n",run2);
printf("the diff is :\n");
printf("\t\tthe inline 's usec is %d \n",run1);
printf("\t\tthe stock 's usec is %d \n",run2);
return 1;
}
int ppp(int n)
{
return ((n)*(n));
}
inline int ppp_inline(int n)
{
return ((n)*(n));
}
两个外部函数。