Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 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. static uint32_t getTick() {
  8. timespec ts;
  9. unsigned theTick = 0U;
  10. clock_gettime( CLOCK_REALTIME, &ts );
  11. theTick = ts.tv_nsec / 1000;
  12. theTick += ts.tv_sec * 1000000;
  13. return theTick;
  14. }
  15.  
  16. int main() {
  17. uint32_t tc;
  18.  
  19. //---------------------------------
  20.  
  21. std::ios::sync_with_stdio(false);
  22.  
  23. tc = getTick();
  24.  
  25. for(int i = 0; i < 1000000; ++i)
  26. {
  27. std::cout << "1234567890ABCDEF";
  28. }
  29.  
  30. tc = getTick() - tc;
  31.  
  32. std::cerr << tc << std::endl;
  33.  
  34. //---------------------------------
  35.  
  36. std::ios::sync_with_stdio(true);
  37.  
  38. tc = getTick();
  39.  
  40. for(int i = 0; i < 1000000; ++i)
  41. {
  42. std::cout << "1234567890ABCDEF";
  43. }
  44.  
  45. tc = getTick() - tc;
  46.  
  47. std::cerr << tc << std::endl;
  48.  
  49. //---------------------------------
  50.  
  51. tc = getTick();
  52.  
  53. for(int i = 0; i < 1000000; ++i)
  54. {
  55. printf("1234567890ABCDEF");
  56. }
  57.  
  58. tc = getTick() - tc;
  59.  
  60. std::cerr << tc << std::endl;
  61.  
  62. //---------------------------------
  63.  
  64. tc = getTick();
  65.  
  66. for(int i = 0; i < 1000000; ++i)
  67. {
  68. printf("%s", "1234567890ABCDEF");
  69. }
  70.  
  71. tc = getTick() - tc;
  72.  
  73. std::cerr << tc << std::endl;
  74.  
  75. //---------------------------------
  76. //---------------------------------
  77.  
  78. return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement