1 Star 0 Fork 0

via/bundle

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
demo.cc 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
r-lyeh 提交于 2017-10-07 15:55 . v2.1.0
#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;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/chooosky/bundle.git
[email protected]:chooosky/bundle.git
chooosky
bundle
bundle
master

搜索帮助