Newer
Older
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
#include <iostream>
#include <string>
#include <string_view>
#include "thirdparty/parser.hpp"
using namespace aria::csv;
int64_t ToInt(std::string_view s) {
int64_t result = 0;
for (auto c : s) result = result * 10 + (c - '0');
return result;
}
int64_t sum_extendedprice(const std::string& file_name) {
std::ifstream f(file_name);
CsvParser lineitem = CsvParser(f).delimiter('|');
int64_t price_sum = 0;
uint64_t field_number = 0;
for (auto row : lineitem) {
for (const auto& field : row) {
//-- TODO exercise 2.5
// your code goes here
//--
}
}
return price_sum;
}
// Tasks:
// * Compare this to awk execution time
// * Estimate how fast the program can possibly be on you local machine. Assume
// that the input file is read from memory
// * Find out where most of the time is spent and why this program is not even
// close to your estimates. Tools that can help here: perf stat, perf record,
// perf report
// *