Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdint.h>
- #include <sys/time.h>
- #include <ctime>
- using namespace std;
- int main(int argc, char *argv[]) {
- struct timespec time_start={0, 0},time_end={0, 0};
- uint8_t bitmap[20240];
- int cost;
- clock_gettime(CLOCK_REALTIME, &time_start);
- for (int i = 0; i < 20240; ++i) {
- bitmap[i >> 3] |= 1 << (i&7);
- }
- clock_gettime(CLOCK_REALTIME, &time_end);
- cost = time_end.tv_nsec - time_start.tv_nsec;
- cout << "case COST: " << cost << endl;
- clock_gettime(CLOCK_REALTIME, &time_start);
- for (int i = 0; i < 20240; ++i) {
- bitmap[i >> 3] &= 1 << (i&7);
- }
- clock_gettime(CLOCK_REALTIME, &time_end);
- cost = time_end.tv_nsec - time_start.tv_nsec;
- cout << "case COST: " << cost << endl;
- int a = bitmap[1];
- std::cout << "TEST: " << a << endl;
- }
Add Comment
Please, Sign In to add comment