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

Feature/performance improvements #4

Merged
merged 11 commits into from
Apr 22, 2020
Merged
Prev Previous commit
Next Next commit
Switched to using mmap + 0 allocations. Almost there
  • Loading branch information
p-ranav committed Apr 21, 2020
commit 487cd4c2d7a4189f111615935c2334913c1fb8e1
36 changes: 14 additions & 22 deletions benchmark/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,24 @@ int main(int argc, char **argv) {
};

// Measurement 1: Loading file
auto m1_start = std::chrono::high_resolution_clock::now();
auto start = std::chrono::high_resolution_clock::now();

Reader csv{
option::Delimiter{','}, option::SkipInitialSpace{true}
// ...
};
if (csv.open(argv[1])) {
auto m1_stop = std::chrono::high_resolution_clock::now();
auto m2_start = m1_stop;

size_t i = 0;
Row next;
while (csv.read_row(next)) {
i += 1;
Reader<',','"'> csv;
if (csv.read(argv[1])) {
size_t rows{0}, cells{0};
for (auto row : csv) {
rows += 1;
for (auto cell: row) {
cells += 1;
}
}
auto m2_stop = std::chrono::high_resolution_clock::now();
auto stop = std::chrono::high_resolution_clock::now();

std::cout << "Stats:\n";
std::cout << "Rows: " << i << "\n";
std::cout << "Cols: " << csv.cols() << "\n";
std::cout << "Measurement 1: ";
print_exec_time(m1_start, m1_stop);
std::cout << "Measurement 2: ";
print_exec_time(m2_start, m2_stop);
std::cout << "Total Execution Time: ";
print_exec_time(m1_start, m2_stop);
std::cout << "Rows: " << rows << "\n";
std::cout << "Cols: " << cells / rows << "\n";
std::cout << "Execution Time: ";
print_exec_time(start, stop);
}
else {
std::cout << "error: Failed to open " << argv[1] << std::endl;
Expand Down
Loading