Guest User

Untitled

a guest
Jan 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.90 KB | None | 0 0
  1. 5 == 100 F
  2. 43 == 100 F
  3. 100 == 100 T
  4. 250 == 100 F
  5. 6 == 100 F
  6. (other elements to check)
  7.  
  8. 5 == 100 F
  9. 6 == 100 F
  10. 43 == 100 F
  11. 100 == 100 T
  12. (no need to check other elements, so all are F)
  13.  
  14. srand(time(NULL));
  15. int UNSORTEDARRAY[524288];
  16. int SORTEDARRAY[sizeof(UNSORTEDARRAY)/sizeof(int)];
  17. for(int i=0;i<sizeof(SORTEDARRAY)/sizeof(int);i++){
  18. SORTEDARRAY[i]=UNSORTEDARRAY[i]=rand();
  19. }
  20. sort(SORTEDARRAY,SORTEDARRAY+sizeof(SORTEDARRAY)/sizeof(int));
  21. string u="const int UNSORTEDARRAY[]={";
  22. string s="const int SORTEDARRAY[]={";
  23. for(int i=0;i<sizeof(UNSORTEDARRAY)/sizeof(int);i++){
  24. u+=to_string(UNSORTEDARRAY[i])+",";
  25. s+=to_string(SORTEDARRAY[i])+",";
  26. }
  27. u.erase(u.end()-1);
  28. s.erase(s.end()-1);
  29. u+="};n";
  30. s+="};n";
  31. ofstream out("number.h");
  32. string code=u+s;
  33. out << code;
  34. out.close();
  35.  
  36. #include "number.h"
  37. int main(){
  38. int count;
  39. clock_t start = clock();
  40. for(int i=0;i<sizeof(SORTEDARRAY)/sizeof(int);i++){
  41. if(SORTEDARRAY[i]==RAND_MAX/2){
  42. count++;
  43. }
  44. }
  45. printf("%fn",(float)(clock()-start)/CLOCKS_PER_SEC);
  46. }
  47.  
  48. 0.005376
  49. 0.005239
  50. 0.005220
  51.  
  52. 0.005334
  53. 0.005120
  54. 0.005223
  55.  
  56. 0.008407
  57. 0.008363
  58. 0.008606
  59.  
  60. 0.005306
  61. 0.005227
  62. 0.005146
  63.  
  64. jason@io /tmp $ lz4 -d ints | perf stat ./proc-eq >/dev/null
  65. Successfully decoded 104824717 bytes
  66.  
  67. Performance counter stats for './proc-eq':
  68.  
  69. 5226.932577 task-clock (msec) # 0.953 CPUs utilized
  70. 31 context-switches # 0.006 K/sec
  71. 24 cpu-migrations # 0.005 K/sec
  72. 3,479 page-faults # 0.666 K/sec
  73. 15,763,486,767 cycles # 3.016 GHz
  74. 4,238,973,549 stalled-cycles-frontend # 26.89% frontend cycles idle
  75. <not supported> stalled-cycles-backend
  76. 31,522,072,416 instructions # 2.00 insns per cycle
  77. # 0.13 stalled cycles per insn
  78. 8,515,545,178 branches # 1629.167 M/sec
  79. 10,261,743 branch-misses # 0.12% of all branches
  80.  
  81. 5.483071045 seconds time elapsed
  82.  
  83. jason@io /tmp $ lz4 -d ints | sort -n | perf stat ./proc-eq >/dev/null
  84. Successfully decoded 104824717 bytes
  85.  
  86. Performance counter stats for './proc-eq':
  87.  
  88. 5536.031410 task-clock (msec) # 0.348 CPUs utilized
  89. 198 context-switches # 0.036 K/sec
  90. 21 cpu-migrations # 0.004 K/sec
  91. 3,604 page-faults # 0.651 K/sec
  92. 16,870,541,124 cycles # 3.047 GHz
  93. 5,300,218,855 stalled-cycles-frontend # 31.42% frontend cycles idle
  94. <not supported> stalled-cycles-backend
  95. 31,526,006,118 instructions # 1.87 insns per cycle
  96. # 0.17 stalled cycles per insn
  97. 8,516,336,829 branches # 1538.347 M/sec
  98. 10,980,571 branch-misses # 0.13% of all branches
  99.  
  100. jason@io /tmp $ lz4 -d ints | perf stat ./proc-gt >/dev/null
  101. Successfully decoded 104824717 bytes
  102.  
  103. Performance counter stats for './proc-gt':
  104.  
  105. 5293.065703 task-clock (msec) # 0.957 CPUs utilized
  106. 38 context-switches # 0.007 K/sec
  107. 50 cpu-migrations # 0.009 K/sec
  108. 3,466 page-faults # 0.655 K/sec
  109. 15,972,451,322 cycles # 3.018 GHz
  110. 4,350,726,606 stalled-cycles-frontend # 27.24% frontend cycles idle
  111. <not supported> stalled-cycles-backend
  112. 31,537,365,299 instructions # 1.97 insns per cycle
  113. # 0.14 stalled cycles per insn
  114. 8,515,606,640 branches # 1608.823 M/sec
  115. 15,241,198 branch-misses # 0.18% of all branches
  116.  
  117. 5.532285374 seconds time elapsed
  118.  
  119. jason@io /tmp $ lz4 -d ints | sort -n | perf stat ./proc-gt >/dev/null
  120.  
  121. 15.930144154 seconds time elapsed
  122.  
  123. Performance counter stats for './proc-gt':
  124.  
  125. 5203.873321 task-clock (msec) # 0.339 CPUs utilized
  126. 7 context-switches # 0.001 K/sec
  127. 22 cpu-migrations # 0.004 K/sec
  128. 3,459 page-faults # 0.665 K/sec
  129. 15,830,273,846 cycles # 3.042 GHz
  130. 4,456,369,958 stalled-cycles-frontend # 28.15% frontend cycles idle
  131. <not supported> stalled-cycles-backend
  132. 31,540,409,224 instructions # 1.99 insns per cycle
  133. # 0.14 stalled cycles per insn
  134. 8,516,186,042 branches # 1636.509 M/sec
  135. 10,205,058 branch-misses # 0.12% of all branches
  136.  
  137. 15.365528326 seconds time elapsed
Add Comment
Please, Sign In to add comment