Guest User

Bypass1G

a guest
Jun 20th, 2022
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 KB | None | 0 0
  1. #include <fcntl.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <sys/mman.h>
  6. #include <sys/stat.h>
  7. #include <sys/time.h>
  8. #include <unistd.h>
  9. long fsize(int fd) {
  10. struct stat stat;
  11. int res = fstat(fd, &stat);
  12. return stat.st_size;
  13. }
  14. int main() {
  15. int32_t block0 = open("/scratch1/das160/dfsdata/datanode/current/"
  16. "BP-1337554057-128.10.4.25-1653193496214/current/"
  17. "finalized/subdir0/subdir4/blk_1073743092",
  18. 0);
  19. int32_t block1 = open("/scratch1/das160/dfsdata/datanode/current/"
  20. "BP-1337554057-128.10.4.25-1653193496214/current/"
  21. "finalized/subdir0/subdir4/blk_1073743093",
  22. 0);
  23. int32_t block2 = open("/scratch1/das160/dfsdata/datanode/current/"
  24. "BP-1337554057-128.10.4.25-1653193496214/current/"
  25. "finalized/subdir0/subdir4/blk_1073743094",
  26. 0);
  27. int32_t block3 = open("/scratch1/das160/dfsdata/datanode/current/"
  28. "BP-1337554057-128.10.4.25-1653193496214/current/"
  29. "finalized/subdir0/subdir4/blk_1073743095",
  30. 0);
  31. int32_t block4 = open("/scratch1/das160/dfsdata/datanode/current/"
  32. "BP-1337554057-128.10.4.25-1653193496214/current/"
  33. "finalized/subdir0/subdir4/blk_1073743096",
  34. 0);
  35. int32_t block5 = open("/scratch1/das160/dfsdata/datanode/current/"
  36. "BP-1337554057-128.10.4.25-1653193496214/current/"
  37. "finalized/subdir0/subdir4/blk_1073743097",
  38. 0);
  39. int32_t block6 = open("/scratch1/das160/dfsdata/datanode/current/"
  40. "BP-1337554057-128.10.4.25-1653193496214/current/"
  41. "finalized/subdir0/subdir4/blk_1073743098",
  42. 0);
  43. int32_t block7 = open("/scratch1/das160/dfsdata/datanode/current/"
  44. "BP-1337554057-128.10.4.25-1653193496214/current/"
  45. "finalized/subdir0/subdir4/blk_1073743099",
  46. 0);
  47. long count = 0;
  48. int64_t size0 = fsize(block0);
  49. int64_t size1 = fsize(block1);
  50. int64_t size2 = fsize(block2);
  51. int64_t size3 = fsize(block3);
  52. int64_t size4 = fsize(block4);
  53. int64_t size5 = fsize(block5);
  54. int64_t size6 = fsize(block6);
  55. int64_t size7 = fsize(block7);
  56. struct timeval t1;
  57. gettimeofday(&t1, NULL);
  58. long t1s = t1.tv_sec * 1000000L + t1.tv_usec;
  59. for (int j = 0; j < 8; j++) {
  60. char *file;
  61. int64_t size;
  62. if (j == 0) {
  63. size = size0;
  64. file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block0, 0);
  65. } else if (j == 1) {
  66. size = size1;
  67. file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block1, 0);
  68. } else if (j == 2) {
  69. size = size2;
  70. file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block2, 0);
  71. } else if (j == 3) {
  72. size = size3;
  73. file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block3, 0);
  74. } else if (j == 4) {
  75. size = size4;
  76. file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block4, 0);
  77. } else if (j == 5) {
  78. size = size5;
  79. file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block5, 0);
  80. } else if (j == 6) {
  81. size = size6;
  82. file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block6, 0);
  83. } else if (j == 7) {
  84. size = size7;
  85. file = (char *)mmap(0, size, PROT_READ, MAP_SHARED, block7, 0);
  86. }
  87. for (long i = 0; i < size; i++) {
  88. if (file[i] != ' ')
  89. count++;
  90. }
  91. }
  92. struct timeval t2;
  93. gettimeofday(&t2, NULL);
  94. long t2s = t2.tv_sec * 1000000L + t2.tv_usec;
  95. printf("Time = %ld\n", t2s - t1s);
  96. printf("Count = %ld\n", count);
  97. close(block0);
  98. close(block1);
  99. close(block2);
  100. close(block3);
  101. close(block4);
  102. close(block5);
  103. close(block6);
  104. close(block7);
  105. return 1;
  106. }
  107.  
Advertisement
Add Comment
Please, Sign In to add comment