-
Notifications
You must be signed in to change notification settings - Fork 90
/
demo.cc
46 lines (40 loc) · 1.3 KB
/
demo.cc
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
#include <fstream>
#include <sstream>
#include "bundle.h"
#ifdef _MSC_VER
#include <omp.h>
#endif
int main(int argc, const char **argv) {
using namespace bundle;
using namespace std;
// 23 mb dataset
string original( "There's a lady who's sure all that glitters is gold" );
for (int i = 0; i < 18; ++i) original += original + string( i + 1, 32 + i );
// argument file?
if( argc > 1 ) {
ifstream ifs( argv[1], ios::binary );
stringstream ss;
ss << ifs.rdbuf();
original = ss.str();
}
// pack, unpack & verify all encoders
vector<unsigned> libs {
RAW, SHOCO, LZ4F, MINIZ, LZIP, LZMA20,
ZPAQ, LZ4, BROTLI9, ZSTD, LZMA25,
BSC, BROTLI11, SHRINKER, CSC20, BCM,
ZLING, MCM, TANGELO, ZMOLLY, CRUSH, LZJB
};
for( auto &lib : libs ) {
#ifdef _MSC_VER
double t = omp_get_wtime();
#endif
string packed = pack(lib, original);
string unpacked = unpack(packed);
cout << original.size() << " <--> " << packed.size() << " bytes (" << name_of(lib) << ")";
#ifdef _MSC_VER
cout << " " << ((omp_get_wtime() - t)*1000) << "ms.";
#endif
if( original == unpacked ) cout << endl; else cout << " (failed)" << endl;
}
cout << "All ok." << endl;
}