aboutsummaryrefslogtreecommitdiff
path: root/src/sandbox.c
blob: 957d3185e34ce6b32f4bde0c3cfa9d063948ad95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>

#include "utils.h"
#include "file-scanner.h"

int
main (void)
{
  // const char *filename = "./res/users_data.csv";
  const char *filename = "./res/transactions_data.csv";
  int fd = open (filename, O_RDONLY);

  if (0) {
    MEASURE_SCOPE ("mmap");
    struct string_view sv = mmap_whole (fd);
    struct scanner sc;
    scanner__init (&sc, sv);
    while (!scanner__reached_end (&sc)) {
      static size_t i = 0;
      struct string_view sv = scanner__get_until (&sc, '\n');
      sc.cursor += 1;
      // if (i > 13300000)
      //   printf ("%s:%lu: " STRING_VIEW__FMT "\n", filename, ++i, STRING_VIEW__FMTA (sv));
      i += 1;
      if (i > 13300000) break;
    }
    munmap (&sv.begin, STRING_VIEW__LENGTH (sv));
  }

  if (1) {
    MEASURE_SCOPE ("io_uring");
    struct file_scanner fs;
    file_scanner__init (&fs, fd);
    while (!file_scanner__reached_end (&fs)) {
      static size_t i = 0;
      struct string_view sv = file_scanner__get_until (&fs, '\n');
      file_scanner__skip_n (&fs, 1);
      // if (i > 13300000)
      //   printf ("%s:%lu: %lX/%lX/%lX " STRING_VIEW__FMT "\n", filename, i,
      //           fs.input_scanned, fs.input_submitted, fs.input_size,
      //           STRING_VIEW__FMTA (sv));
      i += 1;
      if (i > 13300000) break;
    }
    file_scanner__deinit (&fs);
  }

  close (fd);

  return EXIT_SUCCESS;
}