zoukankan      html  css  js  c++  java
  • zip压缩文件测试

    http://tech.it168.com/a2009/0604/583/000000583382_5.shtml

    //webmethod序列化数据
            privatevoid btnSerial_Click(object sender, EventArgs e)
            {
               
    try
                {
                   
    this.dtGrid.DataSource =null;
                    DataSet ds
    =new DataSet();
                    DateTime dtBegin
    = DateTime.Now;
                   
    byte[] datas = ws.GetDataSetBytes();
                    DateTime dtDown
    = DateTime.Now;

                    ds
    = (DataSet)ComZipClass.zip.objXmlDeserialize(datas, typeof(DataSet));
                    DateTime dtSerial
    = DateTime.Now;
                   
    this.dtGrid.DataSource = ds.Tables[0];
                    MessageBox.Show(
    string.Format("下载耗时:{0},解压序列化数据耗时:{1},绑定数据耗时:{2},数据量:{3}",
                    dtDown
    - dtBegin,dtSerial-dtDown, DateTime.Now - dtDown, datas.Length));
                }
               
    catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
           
    //序列化并压缩BZIP后数据
            privatevoid btnBZip_Click(object sender, EventArgs e)
            {
               
    try
                {
                   
    this.dtGrid.DataSource =null;
                    DataSet ds
    =new DataSet();
                    DateTime dtBegin
    = DateTime.Now;
                   
    byte[] datas = ws.GetBZiipCompress();
                    DateTime dtDown
    = DateTime.Now;
                   
    byte[] uzip = ComZipClass.zip.BZipDeCompress(datas);
                    DateTime dtUnzip
    = DateTime.Now;
                    ds
    = (DataSet)ComZipClass.zip.objXmlDeserialize(uzip, typeof(DataSet));
                    DateTime dtSerial
    = DateTime.Now;
                   
    this.dtGrid.DataSource = ds.Tables[0];
                     MessageBox.Show(
    string.Format("下载耗时:{0},解压BZIP耗时:{1},解压序列化耗时:{2},绑定数据耗时:{3},数据量:{4}",
                    dtDown
    - dtBegin, dtUnzip - dtDown, dtSerial - dtUnzip, DateTime.Now - dtSerial, datas.Length));
                }
               
    catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
           
    //序列化并压缩Deflate后数据
            privatevoid btnDeflater_Click(object sender, EventArgs e)
            {
               
    try
                {
                   
    this.dtGrid.DataSource =null;
                    DataSet ds
    =new DataSet();
                    DateTime dtBegin
    = DateTime.Now;
                   
    byte[] datas = ws.GetDeflaterCompress();
                    DateTime dtDown
    = DateTime.Now;
                   
    byte[] uzip = ComZipClass.zip.DeflaterDeCompress(datas);
                    DateTime dtUnzip
    = DateTime.Now;
                    ds
    = (DataSet)ComZipClass.zip.objXmlDeserialize(uzip, typeof(DataSet));
                    DateTime dtSerial
    = DateTime.Now;
                   
    this.dtGrid.DataSource = ds.Tables[0];
                    MessageBox.Show(
    string.Format("下载耗时:{0},解压Deflater耗时:{1},解压序列化耗时:{2},绑定数据耗时:{3},数据量:{4}",
                   dtDown
    - dtBegin, dtUnzip - dtDown, dtSerial - dtUnzip, DateTime.Now - dtSerial, datas.Length));
                }
               
    catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
           
    //序列化并压缩GZIP后数据
            privatevoid btnGZip_Click(object sender, EventArgs e)
            {
               
    try
                {
                   
    this.dtGrid.DataSource =null;
                    DataSet ds
    =new DataSet();
                    DateTime dtBegin
    = DateTime.Now;
                   
    byte[] datas = ws.GetGZipCompress();
                    DateTime dtDown
    = DateTime.Now;
                   
    byte[] uzip = ComZipClass.zip.GZipDeCompress(datas);
                    DateTime dtUnzip
    = DateTime.Now;
                    ds
    = (DataSet)ComZipClass.zip.objXmlDeserialize(uzip, typeof(DataSet));
                    DateTime dtSerial
    = DateTime.Now;
                   
    this.dtGrid.DataSource = ds.Tables[0];
                    MessageBox.Show(
    string.Format("下载耗时:{0},解压GZIP耗时:{1},解压序列化耗时:{2},绑定数据耗时:{3},数据量:{4}",
                   dtDown
    - dtBegin, dtUnzip - dtDown, dtSerial - dtUnzip, DateTime.Now - dtSerial, datas.Length));
                }
               
    catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
           
    //序列化并压缩ZIP后数据
            privatevoid btnZip_Click(object sender, EventArgs e)
            {
               
    try
                {
                   
    this.dtGrid.DataSource =null;
                    DataSet ds
    =new DataSet();
                    DateTime dtBegin
    = DateTime.Now;
                   
    byte[] datas = ws.GetZipCompress();
                    DateTime dtDown
    = DateTime.Now;
                   
    byte[] uzip = ComZipClass.zip.ZipDeCompress(datas);
                    DateTime dtUnzip
    = DateTime.Now;
                    ds
    = (DataSet)ComZipClass.zip.objXmlDeserialize(uzip, typeof(DataSet));
                    DateTime dtSerial
    = DateTime.Now;
                   
    this.dtGrid.DataSource = ds.Tables[0];
                    MessageBox.Show(
    string.Format("下载耗时:{0},解压ZIP耗时:{1},解压序列化耗时:{2},绑定数据耗时:{3},数据量:{4}",
                   dtDown
    - dtBegin, dtUnzip - dtDown, dtSerial - dtUnzip, DateTime.Now - dtSerial, datas.Length));
                }
               
    catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

  • 相关阅读:
    Android开发 ViewConfiguration View的配置信息类
    Android 开发 倒计时功能 转载
    Android 开发 关于7.0 FileUriExposedException异常 详解
    Android 开发 实现文本搜索功能
    Android 开发 Activity里获取View的宽度和高度 转载
    Android 开发 存储目录的详解
    Android 开发 Fresco框架点击小图显示全屏大图实现 ZoomableDraweeView
    Android 开发 将window变暗
    Android 开发 DisplayMetrics获取Android设备的屏幕高宽与其他信息
    Android 开发 DP、PX、SP转换详解
  • 原文地址:https://www.cnblogs.com/mingyongcheng/p/3312303.html
Copyright © 2011-2022 走看看