Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <time.h>
  4. #include <stdint.h>
  5. #include <iostream>
  6.  
  7. /*
  8. sla@sla-Inspiron-5720:~$ ./ios > /dev/null
  9. 44294
  10. 39727
  11. 71075
  12. 130222
  13. sla@sla-Inspiron-5720:~$ ./ios > /dev/null
  14. 42322
  15. 39617
  16. 73667
  17. 134513
  18. sla@sla-Inspiron-5720:~$ ./ios > /dev/null
  19. 53560
  20. 41909
  21. 74061
  22. 132310
  23. sla@sla-Inspiron-5720:~$ ./ios > ~/123.txt
  24. 69455
  25. 157903
  26. 199676
  27. 284772
  28. sla@sla-Inspiron-5720:~$ ./ios > ~/123.txt
  29. 68343
  30. 180498
  31. 170306
  32. 204986
  33.  
  34.  *
  35.  */
  36.  
  37. static uint32_t getTick() {
  38.     timespec ts;
  39.     unsigned theTick = 0U;
  40.     clock_gettime( CLOCK_REALTIME, &ts );
  41.     theTick  = ts.tv_nsec / 1000;
  42.     theTick += ts.tv_sec * 1000000;
  43.     return theTick;
  44. }
  45.  
  46. int main() {
  47.   uint32_t tc;
  48.  
  49.   //---------------------------------
  50.  
  51.   std::ios::sync_with_stdio(false);
  52.  
  53.   tc = getTick();
  54.  
  55.   for(int i = 0; i < 1000000; ++i)
  56.   {
  57.     std::cout << "1234567890ABCDEF";
  58.   }
  59.  
  60.   tc = getTick() - tc;
  61.  
  62.   std::cerr << tc << std::endl;
  63.  
  64.   //---------------------------------
  65.  
  66.   std::ios::sync_with_stdio(true);
  67.  
  68.   tc = getTick();
  69.  
  70.   for(int i = 0; i < 1000000; ++i)
  71.   {
  72.     std::cout << "1234567890ABCDEF";
  73.   }
  74.  
  75.   tc = getTick() - tc;
  76.  
  77.   std::cerr << tc << std::endl;
  78.  
  79.   //---------------------------------
  80.  
  81.   tc = getTick();
  82.  
  83.   for(int i = 0; i < 1000000; ++i)
  84.   {
  85.     printf("1234567890ABCDEF");
  86.   }
  87.  
  88.   tc = getTick() - tc;
  89.  
  90.   std::cerr << tc << std::endl;
  91.  
  92.   //---------------------------------
  93.  
  94.   tc = getTick();
  95.  
  96.   for(int i = 0; i < 1000000; ++i)
  97.   {
  98.     printf("%s", "1234567890ABCDEF");
  99.   }
  100.  
  101.   tc = getTick() - tc;
  102.  
  103.   std::cerr << tc << std::endl;
  104.  
  105.   //---------------------------------
  106.   //---------------------------------
  107.  
  108.   return 0;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement