.Net Remoting的效能研究学习:数据压缩方法
来源:互联网 发布:jdk java se v1.8 编辑:程序博客网 时间:2024/06/05 04:34
.Net Remoting的效能研究学习:数据压缩方法
学习.Net Remoting已有一段时间,对于其初步部署应该倒不是很难,真正应用到系统中则需要考虑的问题逐渐多了起来,.Net Remoting机制其特点可以穿透防火墙,在局域网内速度很快,实现证明是比Web Service快很多,但在广域网测试的时候.Net Remoting(使用TCP)效能明显不如Web Service运行效能,后来通过更改.Net Remoting协议改为HEEP+SOAP方式进行,效能有所改善,网络上很多资料显示Web Service效能明显比.Net Remoting效能快,但个人觉得实用为第一,不必要追求所谓真正的快速,因为没有绝对的快速! 选择机制要考虑到使用范围,开发环境还有网络配置等等因素,选择适合的才是最重要的!在这次.Net Remoting效能改善最大的感受是,尽量少进入通道,尽量一次性读取必要讯息,重复使用离线数据源,并且使用了数据压缩技术,根据网络上的资料修改所得,与大家分享!使用之前需要下载组件: ICSharpCode.SharpZipLib 类库可以从这里下载。
public class ZipHelper { public static byte[] Zip(byte[] data) { return Zip(data, 0, data.Length); } public static byte[] Unzip(byte[] data) { return Unzip(data, 0, data.Length); } public static byte[] Zip(byte[] data, int offset, int size) { MemoryStream inStream = new MemoryStream(data, offset, size); MemoryStream outStream = new MemoryStream(); BZip2.Compress(inStream, outStream, size); byte[] result = outStream.ToArray(); inStream.Close(); outStream.Close(); return result; } public static byte[] Unzip(byte[] data, int offset, int size) { MemoryStream inStream = new MemoryStream(data, offset, size); MemoryStream outStream = new MemoryStream(); BZip2.Decompress(inStream, outStream); byte[] result = outStream.ToArray(); inStream.Close(); outStream.Close(); return result; } /**//**//**//// <summary> /// 序列化 /// </summary> /// <param name="data">要序列化的物件</param> /// <returns>返回存放序列化後的資料緩衝區</returns> public static byte[] Serialize(object aodata) { BinaryFormatter formatter = new BinaryFormatter(); MemoryStream rems = new MemoryStream(); formatter.Serialize(rems, aodata); return rems.GetBuffer(); } /**//**//**//// <summary> /// 反序列化 /// </summary> /// <param name="data">數據緩衝區</param> /// <returns>對象</returns> public static object Deserialize(byte[] abdata) { BinaryFormatter formatter = new BinaryFormatter(); MemoryStream rems = new MemoryStream(abdata); abdata = null; return formatter.Deserialize(rems); } public static Dictionary<string, DataTable> UnZipDictionary(byte[] abDictionary) { Dictionary<string, DataTable> dictonary = new Dictionary<string, DataTable>(); byte[] bdictionary = Unzip(abDictionary); dictonary = (Dictionary<string, DataTable>)Deserialize(bdictionary); return dictonary; } public static byte[] ZipDictionary(Dictionary<string, DataTable> adDictionary) { byte[] bdictionary = Serialize(adDictionary); byte[] dictionary = Zip(bdictionary); return dictionary; } public static DataTable UnZipDataTable(byte[] abDictionary) { DataTable dictonary = new DataTable(); byte[] bdictionary = Unzip(abDictionary); dictonary = (DataTable)Deserialize(bdictionary); return dictonary; } public static byte[] ZipDataTable(DataTable adDictionary) { byte[] bdictionary = Serialize(adDictionary); byte[] dictionary = Zip(bdictionary); return dictionary; } public static Object UnZipObject(byte[] aoObject) { Object mObject = new Object(); byte[] bdictionary = Unzip(aoObject); mObject = (Object)Deserialize(bdictionary); return mObject; } public static byte[] ZipObject(Object aoObject) { byte[] bdictionary = Serialize(aoObject); byte[] dictionary = Zip(bdictionary); return dictionary; }
- .Net Remoting的效能研究学习:数据压缩方法
- remoting的研究
- .NET Remoting的学习之路
- 【源代码】基于扩展贝叶斯方法融合的作战效能评估研究
- 开始学习.net remoting
- 学习.NET remoting 啦!
- .Net Remoting学习笔记
- .Net Remoting学习
- 远程方法回调(.Net Remoting学习四)
- 。net 的remoting 技术
- C#学习笔记:.NET Remoting
- 实用的数据压缩解压缩方法
- 动态语言开发效能的一个案例研究
- Remoting研究
- Remoting研究
- .NET Remoting 的产品特性
- .Net Remoting配置文件的用法
- .Net Remoting配置文件的用法
- 功能点估算法(一)
- 使用Limit参数优化MySQL查询
- Initrd文件制作的老方法
- 敏捷大会,英杰聚首
- 功能点估算法(二)
- .Net Remoting的效能研究学习:数据压缩方法
- js 框架
- 功能点估算法(三)
- 我的DotNet学习历程
- 网页中样式50例
- 琐事
- LY RTOS for WinAVR
- 功能点估算法(四)
- MSSQL SERVER 2008 New Features for Developers