-
Notifications
You must be signed in to change notification settings - Fork 3
/
bench.cpp
34 lines (29 loc) · 998 Bytes
/
bench.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
#include <iostream>
#include <chrono>
#include <unistd.h>
#include "cppbor/cppbor.hpp"
using namespace std;
using namespace std::chrono;
int main()
{
// open file, find it's size
FILE* f=fopen("../cbor-python-wrote", "r");
fseek(f , 0 , SEEK_END);
size_t size=static_cast<size_t>(ftell(f));
rewind(f);
// create and load into buffer
vector<uint8_t> cbor_data_in(size);
fread(cbor_data_in.data(), size, 1, f);
fclose(f);
// decode cbor
sleep(1);
high_resolution_clock::time_point start=high_resolution_clock::now();
cbor_variant cbor_original=cbor_variant::construct_from(cbor_data_in);
high_resolution_clock::time_point end=high_resolution_clock::now();
sleep(1);
// report
duration<float> time_taken=duration_cast<duration<float>>(end-start);
cout << "Places: " << get<cbor_map>(cbor_original).size() << endl;
cout << "Parse time: " << time_taken.count() << endl;
// cout << cbor_original.as_python() << endl;
}