-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencode_time_test.cpp
More file actions
56 lines (48 loc) · 1.42 KB
/
encode_time_test.cpp
File metadata and controls
56 lines (48 loc) · 1.42 KB
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
#ifndef WIN32
#include <unistd.h>
#include <cstdlib>
#include <cstring>
#include <netdb.h>
#else
#include <winsock2.h>
#include <ws2tcpip.h>
#include <wspiapi.h>
#endif
#include <unordered_map>
#include <iostream>
#include <fstream>
#include <time.h>
#include "wqueue.h"
// #include "cc.h"
// #include "test_util.h"
#include "kodo/encode.h"
#include "kodo/decode.h"
#include "./common.h"
#include "../src/common.h"
#include "hashlibpp.h" //md5 lib
#define EPSILON 1e-3
using namespace std;
int main(int argc, char* argv[]){
fstream in(argv[1], ios::in | ios::binary);
const int size = SEGMENT_SIZE;
char* buffer = new char[size];
int seg_num = 0;
uint64_t total_encode_time = 0;
uint64_t total_decode_time = 0;
int cnt = 0;
while(!in.eof()){
in.read(buffer, size);
uint64_t time_before_encode = CTimer::getTime();
vector<uint8_t> data_out;
encode((uint8_t*)buffer, data_out, seg_num++);
uint64_t cur_time = CTimer::getTime();
total_encode_time += cur_time - time_before_encode;
cout << "data encoded" << endl;
vector<uint8_t> decode_data;
decode((char*)data_out.data(), decode_data, ENCODED_BLOCK_NUM);
total_decode_time += CTimer::getTime() - cur_time;
cnt ++;
}
cout << "avg encode time: " << (double)total_encode_time/cnt <<endl;
cout << "avg decode time: " << (double)total_decode_time/cnt <<endl;
}