Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right way of reading a large file without performance loss #45

Closed
jdgarciauc3m opened this issue Jul 13, 2021 · 1 comment
Closed

Right way of reading a large file without performance loss #45

jdgarciauc3m opened this issue Jul 13, 2021 · 1 comment

Comments

@jdgarciauc3m
Copy link

What is the right way of reading a large file without performance loss?

If I try something like:

  scn::owning_file file{"bench_stdio.txt", "r"};
  auto ran = scn::make_result(file);
  double x;
  while ((ran = scn::scan(fan.range(),"{}",x))) {
    v.push_back(x);
  }

Performance seems to be bad.

Can we do this better?

@eliaskosunen
Copy link
Owner

Memory mapped files generally make this faster:

scn::mapped_file file{"bench_stdio.txt"};
auto result = scn::make_result(file);
double d{};
while ((result = scn::scan(result.range(), "{}", d))) {
    v.push_back(d);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants