Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fcntl.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <sys/mman.h>
- #include <sys/stat.h>
- #include <sys/time.h>
- #include <unistd.h>
- long fsize(int fd) {
- struct stat stat;
- int res = fstat(fd, &stat);
- return stat.st_size;
- }
- int main() {
- int32_t block0 = open("/scratch1/das160/dfsdata/datanode/current/"
- "BP-1337554057-128.10.4.25-1653193496214/current/"
- "finalized/subdir0/subdir4/blk_1073743092",
- 0);
- int32_t block1 = open("/scratch1/das160/dfsdata/datanode/current/"
- "BP-1337554057-128.10.4.25-1653193496214/current/"
- "finalized/subdir0/subdir4/blk_1073743093",
- 0);
- int32_t block2 = open("/scratch1/das160/dfsdata/datanode/current/"
- "BP-1337554057-128.10.4.25-1653193496214/current/"
- "finalized/subdir0/subdir4/blk_1073743094",
- 0);
- int32_t block3 = open("/scratch1/das160/dfsdata/datanode/current/"
- "BP-1337554057-128.10.4.25-1653193496214/current/"
- "finalized/subdir0/subdir4/blk_1073743095",
- 0);
- int32_t block4 = open("/scratch1/das160/dfsdata/datanode/current/"
- "BP-1337554057-128.10.4.25-1653193496214/current/"
- "finalized/subdir0/subdir4/blk_1073743096",
- 0);
- int32_t block5 = open("/scratch1/das160/dfsdata/datanode/current/"
- "BP-1337554057-128.10.4.25-1653193496214/current/"
- "finalized/subdir0/subdir4/blk_1073743097",
- 0);
- int32_t block6 = open("/scratch1/das160/dfsdata/datanode/current/"
- "BP-1337554057-128.10.4.25-1653193496214/current/"
- "finalized/subdir0/subdir4/blk_1073743098",
- 0);
- int32_t block7 = open("/scratch1/das160/dfsdata/datanode/current/"
- "BP-1337554057-128.10.4.25-1653193496214/current/"
- "finalized/subdir0/subdir4/blk_1073743099",
- 0);
- long count = 0;
- int64_t size0 = fsize(block0);
- int64_t size1 = fsize(block1);
- int64_t size2 = fsize(block2);
- int64_t size3 = fsize(block3);
- int64_t size4 = fsize(block4);
- int64_t size5 = fsize(block5);
- int64_t size6 = fsize(block6);
- int64_t size7 = fsize(block7);
- struct timeval t1;
- gettimeofday(&t1, NULL);
- long t1s = t1.tv_sec * 1000000L + t1.tv_usec;
- for (int j = 0; j < 8; j++) {
- char *file;
- int64_t size;
- if (j == 0) {
- size = size0;
- file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block0, 0);
- } else if (j == 1) {
- size = size1;
- file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block1, 0);
- } else if (j == 2) {
- size = size2;
- file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block2, 0);
- } else if (j == 3) {
- size = size3;
- file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block3, 0);
- } else if (j == 4) {
- size = size4;
- file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block4, 0);
- } else if (j == 5) {
- size = size5;
- file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block5, 0);
- } else if (j == 6) {
- size = size6;
- file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block6, 0);
- } else if (j == 7) {
- size = size7;
- file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block7, 0);
- }
- for (long i = 0; i < size; i++) {
- if (file[i] != ' ')
- count++;
- }
- }
- struct timeval t2;
- gettimeofday(&t2, NULL);
- long t2s = t2.tv_sec * 1000000L + t2.tv_usec;
- printf("Time = %ld\n", t2s - t1s);
- printf("Count = %ld\n", count);
- close(block0);
- close(block1);
- close(block2);
- close(block3);
- close(block4);
- close(block5);
- close(block6);
- close(block7);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment