-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitial-benchmark.cpp
More file actions
39 lines (29 loc) · 917 Bytes
/
initial-benchmark.cpp
File metadata and controls
39 lines (29 loc) · 917 Bytes
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 <vector>
#include <chrono>
#include "ieee754.hpp"
#include "encoder.hpp"
#include "decoder.hpp"
#include "bitstream.hpp"
int main()
{
using namespace comp;
const int TICKS = 1000000;
std::vector<double> data(TICKS, 150.25);
for(int i{0}; i < TICKS; i+= 10)
{
data[i] += 0.01;
}
Encoder encoder(TICKS * 128); //Pre-allocate memory
auto start = std::chrono::high_resolution_clock::now();
for(const auto &d : data)
{
encoder.append(d);
}
encoder.fin();
auto end = std::chrono::high_resolution_clock::now();
auto time_len = std::chrono::duration_cast<std::chrono::microseconds>(end - start).count();
std::cout << "Processed " << TICKS << " ticks in " << time_len << " microseconds.\n";
std::cout << "Throughput: " << (TICKS / (time_len / 1000000.0)) / 1e6 << " million ticks/sec.\n";
return 0;
}