-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_csv.cpp
72 lines (53 loc) · 1.82 KB
/
test_csv.cpp
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*
*
* Copyright (c) 2016, Lutz, Clemens <lutzcle@cml.li>
*/
#include "csv.hpp"
#include "timer.hpp"
#include "common.hpp"
#include <iostream>
#include <vector>
#include <cstdint>
#include <chrono>
#include <algorithm>
int main(int argc, char **argv) {
char *file_name = argv[1];
cle::CSV csv;
Timer::Timer timer;
uint64_t duration = 0;
std::vector<double> a;
std::vector<double> b;
argc = 0; // suppress compiler warning "unused variable"
std::cout << "Reading from file \"" << file_name << "\"" << std::endl;
timer.start();
csv.read_csv(file_name, a, b);
duration = timer.stop<std::chrono::microseconds>();
std::cout << "Variadic runtime: " << duration << " µs" << std::endl;
// cle::Utils::print_vector(a);
// cle::Utils::print_vector(b);
std::vector<std::vector<double>> array;
timer.start();
csv.read_csv(file_name, array);
duration = timer.stop<std::chrono::microseconds>();
std::cout << "Array runtime: " << duration << " µs" << std::endl;
cle::Matrix<float, std::allocator<float>, uint32_t> matrix;
timer.start();
csv.read_csv(file_name, matrix);
duration = timer.stop<std::chrono::microseconds>();
std::cout << "Matrix runtime: " << duration << " µs" << std::endl;
// for (auto& v : array) {
// cle::Utils::print_vector(v);
// }
if (
not std::equal(a.cbegin(), a.cend(), array[0].cbegin())
||
not std::equal(b.cbegin(), b.cend(), array[1].cbegin())
) {
std::cout << "Mismatch between read_csv and read_csv_dynamic!!"
<< std::endl;
}
}