GZip 压缩测试
来源:互联网 发布:数据透视表求和显示0 编辑:程序博客网 时间:2024/04/29 23:08
用.net 自带的 GZipStream 测试,压缩比率用默认值进行测试
对于3K以下的数据进行压缩,发现数据会越压缩越大,对于大于3K的数据进行压缩才会有效果。
而用第三主工具 ICSharpCode.SharpZipLib; 进行压缩,如果都是用默认的值的话,发现效率跟自带的差挺多的。一个数据级别
/// <summary>
/// GZip 压缩
/// </summary>
/// <param name="inBytes"></param>
/// <returns></returns>
public static byte[] GZipCompress(byte[] inBytes)
{
MemoryStream outStream = new MemoryStream();
using (MemoryStream intStream = new MemoryStream(inBytes))
{
using (GZipStream Compress =new GZipStream(outStream, CompressionMode.Compress))
{
intStream.CopyTo(Compress);
}
}
return outStream.ToArray();
}
/// <summary>
/// GZip 解压
/// </summary>
/// <param name="inStream"></param>
/// <returns></returns>
public static byte[] GZipDecompress(byte[] inStream)
{
byte[] result = null;
MemoryStream compressedStream = new MemoryStream(inStream);
using (MemoryStream outStream = new MemoryStream())
{
using (GZipStream Decompress = new GZipStream(compressedStream, CompressionMode.Decompress))
{
Decompress.CopyTo(outStream);
result = outStream.ToArray();
}
}
return result;
}
/// <summary>
/// 压缩
/// </summary>
/// <param name="bt"></param>
/// <returns></returns>
public static byte[] t1(byte[] bt)
{
MemoryStream outStream = new MemoryStream();
using (MemoryStream intStream = new MemoryStream(bt))
{
using (ICSharpCode.SharpZipLib.GZip.GZipOutputStream Compress = new ICSharpCode.SharpZipLib.GZip.GZipOutputStream(outStream))
{
intStream.CopyTo(Compress);
}
}
return outStream.ToArray();
}
/// <summary>
/// 解压
/// </summary>
/// <param name="bt"></param>
/// <returns></returns>
public static byte[] t2(byte[] bt)
{
byte[] result = null;
MemoryStream compressedStream = new MemoryStream(bt);
using (MemoryStream outStream = new MemoryStream())
{
using (ICSharpCode.SharpZipLib.GZip.GZipInputStream Decompress = new ICSharpCode.SharpZipLib.GZip.GZipInputStream(compressedStream))
{
Decompress.CopyTo(outStream);
result = outStream.ToArray();
}
}
return result;
}
- GZip 压缩测试
- php curl 中的gzip压缩性能测试
- gzip压缩
- GZip压缩
- GZIP压缩
- Gzip压缩
- GZIP压缩
- Gzip压缩
- GZIP压缩
- GZIP --压缩
- Gzip压缩
- GZIP压缩
- Gzip压缩
- gzip压缩
- gzip压缩
- IIS6 启动 gzip 压缩 推荐 附测试是否生效地址
- gzip压缩和解压缩
- 压缩和解压缩GZIP文件
- oracle数据库设计第一次作业
- iframe 传接值 父页面 子页面 传值
- vc6到 vs2008 char* 与 CString 之间 字符串转换函数 .
- Android硬件抽象层(HAL)概要介绍和学习计划
- 远程访问SQL数据库执行查询
- GZip 压缩测试
- HDU 3068 最长回文串
- 在Ubuntu上为Android系统编写Linux内核驱动程序
- 最伟大的计算机程序员是如何诞生的?——解读高德纳(Donald E.Knuth)
- 圆周率求解
- MONO for Android ILocationListener接口实现
- avl实现
- [pgf and tikz]foreach的高级用法:同时循环两个变量
- 当泛型遇到了重载