Boost IO Stream和ZLib加速 [英] Boost IO Stream and ZLib speed up

查看:481
本文介绍了Boost IO Stream和ZLib加速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大数据文件,我使用升压IOStreams和过滤流缓冲区使用Zlib压缩:

  boost :: iostreams :: array_source uncompressedArray(reinterpret_cast< const char *>(& uncompressedData [0]),uncompressedData.size()); 

boost :: iostreams :: filtering_streambuf< boost :: iostreams :: output>出口;
out.push(* m_compressor);
out.push(boost :: iostreams :: char_back_inserter(compressedData));
boost :: iostreams :: copy(uncompressedArray,out);

对于速度,我使用以下命令初始化zlib库:

  boost :: iostreams :: zlib_params params; 
params.level = boost :: iostreams__zlib :: best_speed;
params.mem_level = 9;

m_compressor.reset(new boost :: iostreams :: zlib_compressor(params,131072));
m_decompressor.reset(new boost :: iostreams :: zlib_decompressor(params,131072));

我的解压缩器看起来像这样:

  boost :: iostreams :: array_source compressedArray(reinterpret_cast< const char *>(& compressedData [0]),compressedData.size()); 

boost :: iostreams :: filtering_streambuf< boost :: iostreams :: input> m_in;
m_in.push(* m_decompressor);
m_in.push(compressedArray);
boost :: iostreams :: copy(m_in,boost :: iostreams :: char_back_inserter(uncompressedData));我的问题是有什么方法可以加速充气(解压缩)操作吗?现在压缩大约占我的数据访问时间的83%,我真的需要更快。任何建议都将非常感激。

解决方案

加速解压缩的唯一方法是使压缩数据更小,较少处理。这意味着花费更多的时间压缩,假设你不那么关心这一端的处理时间。所以你会选择最好的压缩。


I have a large file of data I have compressed with Zlib using boost IOStreams and filtering stream buffers:

boost::iostreams::array_source uncompressedArray( reinterpret_cast< const char* >( &uncompressedData[0] ), uncompressedData.size() );

boost::iostreams::filtering_streambuf< boost::iostreams::output > out;
out.push( *m_compressor );
out.push( boost::iostreams::char_back_inserter( compressedData ) );
boost::iostreams::copy( uncompressedArray, out );

For speed I am initializing the zlib library with the following:

boost::iostreams::zlib_params params;
params.level = boost::iostreams__zlib::best_speed;
params.mem_level = 9;

m_compressor.reset( new boost::iostreams::zlib_compressor( params, 131072 ) );
m_decompressor.reset( new boost::iostreams::zlib_decompressor( params, 131072 ) );

My decompressor looks like this:

boost::iostreams::array_source compressedArray( reinterpret_cast< const char* >( &compressedData[0] ), compressedData.size() );

boost::iostreams::filtering_streambuf< boost::iostreams::input > m_in;
m_in.push( *m_decompressor );
m_in.push( compressedArray );       
boost::iostreams::copy( m_in, boost::iostreams::char_back_inserter( uncompressedData ) );

My question is are there any ways I can speed up the inflate (decompress) operation? Right now the compression is taking about 83% of my data access time and I really need to get this faster. Any suggestions would be greatly appreciated.

解决方案

The only way to speed up decompression is to make the compressed data smaller, so it has less to process. That means spending more time compressing, assuming that you're not as concerned about the processing time on that end. So you would select best compression.

这篇关于Boost IO Stream和ZLib加速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆