Advertisement
illwieckz

bench ClearSkyBox #2

Jul 19th, 2021
1,093
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.14 KB | None | 0 0
  1. ```c
  2. #include <string.h>
  3. #include <algorithm>
  4. #include <iterator>
  5. #include <limits>
  6.  
  7. float sky_mins[2][6], sky_maxs[2][6];
  8.  
  9. __attribute__((noinline)) void ClearSkyBox1()
  10. {
  11.     std::fill( *sky_mins, (*sky_mins)+2*6, 9999 );
  12.     std::fill( *sky_maxs, (*sky_maxs)+2*6, -9999 );
  13. }
  14.  
  15. __attribute__((noinline)) void ClearSkyBox2()
  16. {
  17.     static const float mins[ 2 ][ 6 ] = {
  18.         { 9999, 9999, 9999, 9999, 9999, 9999 },
  19.         { 9999, 9999, 9999, 9999, 9999, 9999 }
  20.     };
  21.  
  22.     static const float maxs[ 2 ][ 6 ] = {
  23.         { -9999, -9999, -9999, -9999, -9999, -9999 },
  24.         { -9999, -9999, -9999, -9999, -9999, -9999 }
  25.     };
  26.  
  27.     memcpy( sky_mins, mins, sizeof( mins ) );
  28.     memcpy( sky_maxs, maxs, sizeof( maxs ) );
  29. }
  30.  
  31. int main()
  32. {
  33.     while ( true )
  34.     {
  35.         ClearSkyBox1();
  36.         ClearSkyBox2();
  37.     }
  38. }
  39. ```
  40.  
  41. # gcc -O2
  42.  
  43. * ClearSkyBox1: 51.26%
  44. * ClearSkyBox2: 43.13%
  45.  
  46. ```asm
  47. asm: /* ClearSkyBox1() */
  48. Platform: X86 64 (Intel syntax)
  49. 0x55d41bc4b150: endbr64      
  50. 0x55d41bc4b154: lea          rax, [rip + 0x2f25]
  51. 0x55d41bc4b15b: movss        xmm0, dword ptr [rip + 0xf2d]
  52. 0x55d41bc4b163: lea          rdx, [rax + 0x30]
  53. 0x55d41bc4b167: nop          word ptr [rax + rax]
  54. 0x55d41bc4b170: movss        dword ptr [rax], xmm0
  55. 0x55d41bc4b174: add          rax, 4
  56. 0x55d41bc4b178: cmp          rax, rdx
  57. 0x55d41bc4b17b: jne          0x55d41bc4b170
  58. 0x55d41bc4b17d: lea          rax, [rip + 0x2ebc]
  59. 0x55d41bc4b184: movss        xmm0, dword ptr [rip + 0xf08]
  60. 0x55d41bc4b18c: lea          rdx, [rax + 0x30]
  61. 0x55d41bc4b190: movss        dword ptr [rax], xmm0
  62. 0x55d41bc4b194: add          rax, 4
  63. 0x55d41bc4b198: cmp          rax, rdx
  64. 0x55d41bc4b19b: jne          0x55d41bc4b190
  65. 0x55d41bc4b19d: ret  
  66. 0x55d41bc4b19e:
  67. ```
  68.  
  69. ```asm
  70. asm: /* ClearSkyBox2() */
  71. Platform: X86 64 (Intel syntax)
  72. 0x55d41bc4b1a0: endbr64      
  73. 0x55d41bc4b1a4: movdqa       xmm0, xmmword ptr [rip + 0xeb4]
  74. 0x55d41bc4b1ac: movdqa       xmm1, xmmword ptr [rip + 0xebc]
  75. 0x55d41bc4b1b4: movdqa       xmm2, xmmword ptr [rip + 0xec4]
  76. 0x55d41bc4b1bc: movdqa       xmm3, xmmword ptr [rip + 0xe5c]
  77. 0x55d41bc4b1c4: movdqa       xmm4, xmmword ptr [rip + 0xe64]
  78. 0x55d41bc4b1cc: movdqa       xmm5, xmmword ptr [rip + 0xe6c]
  79. 0x55d41bc4b1d4: movaps       xmmword ptr [rip + 0x2ea5], xmm0
  80. 0x55d41bc4b1db: movaps       xmmword ptr [rip + 0x2eae], xmm1
  81. 0x55d41bc4b1e2: movaps       xmmword ptr [rip + 0x2eb7], xmm2
  82. 0x55d41bc4b1e9: movaps       xmmword ptr [rip + 0x2e50], xmm3
  83. 0x55d41bc4b1f0: movaps       xmmword ptr [rip + 0x2e59], xmm4
  84. 0x55d41bc4b1f7: movaps       xmmword ptr [rip + 0x2e62], xmm5
  85. 0x55d41bc4b1fe: ret          
  86. 0x55d41bc4b1ff:
  87. ```
  88.  
  89. # gcc -O3
  90.  
  91. * ClearSkyBox1: 68.17%
  92. * ClearSkyBox2: 22.81%
  93.  
  94. ```asm
  95. asm: /* ClearSkyBox1() */
  96. Platform: X86 64 (Intel syntax)
  97. 0x55b02e8b1150: endbr64      
  98. 0x55b02e8b1154: movaps       xmm0, xmmword ptr [rip + 0xf35]
  99. 0x55b02e8b115b: movaps       xmmword ptr [rip + 0x2f1e], xmm0
  100. 0x55b02e8b1162: movaps       xmmword ptr [rip + 0x2f27], xmm0
  101. 0x55b02e8b1169: movaps       xmmword ptr [rip + 0x2f30], xmm0
  102. 0x55b02e8b1170: movaps       xmm0, xmmword ptr [rip + 0xf29]
  103. 0x55b02e8b1177: movaps       xmmword ptr [rip + 0x2ec2], xmm0
  104. 0x55b02e8b117e: movaps       xmmword ptr [rip + 0x2ecb], xmm0
  105. 0x55b02e8b1185: movaps       xmmword ptr [rip + 0x2ed4], xmm0
  106. 0x55b02e8b118c: ret          
  107. 0x55b02e8b118d:
  108. ```
  109.  
  110. ```asm
  111. asm: /* ClearSkyBox2() */
  112. Platform: X86 64 (Intel syntax)
  113. 0x55b02e8b1190: endbr64      
  114. 0x55b02e8b1194: movdqa       xmm0, xmmword ptr [rip + 0xec4]
  115. 0x55b02e8b119c: movdqa       xmm1, xmmword ptr [rip + 0xecc]
  116. 0x55b02e8b11a4: movdqa       xmm2, xmmword ptr [rip + 0xed4]
  117. 0x55b02e8b11ac: movdqa       xmm3, xmmword ptr [rip + 0xe6c]
  118. 0x55b02e8b11b4: movdqa       xmm4, xmmword ptr [rip + 0xe74]
  119. 0x55b02e8b11bc: movdqa       xmm5, xmmword ptr [rip + 0xe7c]
  120. 0x55b02e8b11c4: movaps       xmmword ptr [rip + 0x2eb5], xmm0
  121. 0x55b02e8b11cb: movaps       xmmword ptr [rip + 0x2ebe], xmm1
  122. 0x55b02e8b11d2: movaps       xmmword ptr [rip + 0x2ec7], xmm2
  123. 0x55b02e8b11d9: movaps       xmmword ptr [rip + 0x2e60], xmm3
  124. 0x55b02e8b11e0: movaps       xmmword ptr [rip + 0x2e69], xmm4
  125. 0x55b02e8b11e7: movaps       xmmword ptr [rip + 0x2e72], xmm5
  126. 0x55b02e8b11ee: ret          
  127. 0x55b02e8b11ef:
  128. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement