Guest User

Untitled

a guest
Oct 22nd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdint.h>
  3. #include <sys/time.h>
  4. #include <ctime>
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char *argv[]) {
  9. struct timespec time_start={0, 0},time_end={0, 0};
  10. uint8_t bitmap[20240];
  11. int cost;
  12. clock_gettime(CLOCK_REALTIME, &time_start);
  13. for (int i = 0; i < 20240; ++i) {
  14. bitmap[i >> 3] |= 1 << (i&7);
  15. }
  16. clock_gettime(CLOCK_REALTIME, &time_end);
  17. cost = time_end.tv_nsec - time_start.tv_nsec;
  18. cout << "case COST: " << cost << endl;
  19. clock_gettime(CLOCK_REALTIME, &time_start);
  20. for (int i = 0; i < 20240; ++i) {
  21. bitmap[i >> 3] &= 1 << (i&7);
  22. }
  23. clock_gettime(CLOCK_REALTIME, &time_end);
  24. cost = time_end.tv_nsec - time_start.tv_nsec;
  25. cout << "case COST: " << cost << endl;
  26. int a = bitmap[1];
  27. std::cout << "TEST: " << a << endl;
  28.  
  29. }
Add Comment
Please, Sign In to add comment