christophe_d13 L'efficacité à tout prix. | Code :
- {
- DWORD dw1, dw2, dwCount1, dwCount2;
- unsigned char Source;
- char szTmp[256];
- #define COUNTLEN 10000000
- Source = 156;
- __asm {
- rdtsc
- mov dw1, eax
- mov ecx, COUNTLEN
- xor eax, eax
-
- loop_reorder1:
- mov al, Source //al = 76543210
- mov bl, al //al = 65432107
- rol al, 1
- rol bl, 5 //bl = 21076543
- and al, 0x99 //al = 6xx32xx7
- and bl, 0x66 //bl = x10xx54x
- or al, bl //al = 61032547
- mov bl, al //bl = 61032547
-
- and al, 0x55 //al = x1x3x5x7
- and bl, 0xAA //bl = 6x0x2x4x
- rol bl, 2 //bl = 0x2x4x6x
- or al, bl //al = 01234567
- dec ecx
- jnz loop_reorder1
- mov Source, al
- rdtsc
- mov dw2, eax
- }
- dwCount1 = dw2 - dw1;
- __asm {
- rdtsc
- mov dw1, eax
- mov ecx, COUNTLEN
- xor eax, eax
- loop_reorder2:
- dec ecx
- jnz loop_reorder2
- rdtsc
- mov dw2, eax
- }
- dwCount2 = dw2 - dw1;
- sprintf ( szTmp, "%4.1f cycles", ((float)(dwCount1-dwCount2))/COUNTLEN );
- MessageBox ( GetFocus ( ), szTmp, "DebugBox", MB_OK );
- return 0;
- }
|
|