POI 的简单版本 EasyPoi性能测试 系列一

1.基础功能导出测试
    测试用例,导出5行数据,一个关联类,25000或者5W行数据
测试demo
主对象
public  class  MsgClient  implements  java.io.Serializable {
     /** id */
     private  java.lang.String id;
     // 电话号码(主键)
     @Excel (name =  "电话号码" , width =  20 , orderNum =  "2" )
     private  String           clientPhone =  null ;
     // 客户姓名
     @Excel (name =  "姓名" , orderNum =  "1" )
     private  String           clientName  =  null ;
     // 所属分组
     @ExcelEntity
     private  MsgClientGroup   group       =  null ;
     // 备注
     @Excel (name =  "备注" )
     private  String           remark      =  null ;
     // 生日
     @Excel (name =  "出生日期" , format =  "yyyy-MM-dd" , width =  20 )
     private  Date             birthday    =  null ;
     // 创建人
     private  String           createBy    =  null ;
    
关联对象
public  class  MsgClientGroup  implements  Serializable {
 
     /**
     
      */
     private  static  final  long  serialVersionUID = 6946265640897464878L;
 
     // 组名
     @Excel (name =  "分组" )
     private  String            groupName        =  null ;
     /**
      * 创建人
      */
     private  String            createBy;

测试代码
  @Test
  public  void  test()  throws  Exception {
 
         List<MsgClient> list =  new  ArrayList<MsgClient>();
         for  ( int  i =  0 ; i <  25000 ; i++) {
             MsgClient client =  new  MsgClient();
             client.setBirthday( new  Date());
             client.setClientName( "小明"  + i);
             client.setClientPhone( "18797"  + i);
             client.setCreateBy( "jueyue" );
             client.setId( "1"  + i);
             client.setRemark( "测试"  + i);
             MsgClientGroup group =  new  MsgClientGroup();
             group.setGroupName( "测试"  + i);
             client.setGroup(group);
             list.add(client);
         }
         Date start =  new  Date();
         Workbook workbook = ExcelExportUtil.exportExcel( new  ExportParams( "2412312" "测试" ),
             MsgClient. class , list);
         System.out.println( new  Date().getTime() - start.getTime());
         File savefile =  new  File( "d:/" );
         if  (!savefile.exists()) {
             savefile.mkdirs();
         }
         FileOutputStream fos =  new  FileOutputStream( "d:/tt.xls" );
         workbook.write(fos);
         fos.close();
     }
测试结果
     导出用时
03版本
测试No
数据量
用时
1
25000
1381
2
25000
1292
3
50000
1551
4
50000
1604
07版本
测试No
数据量
用时
1
25000
6276
2
25000
6342
3
50000
10014
4
50000
9897


07版本,修改了写入类,改成了SXSSFWorkbook
测试No
数据量
用时
1
25000
3224
2
25000
3457
3
50000
4044
4
50000
3924

说明对大数据量的导出,03版本的Excel基本模板基本上没有在时间上面对性能做出影响
但是07版本的导出,在时间上有较大的差异,在修改成 SXSSFWorkbook导出时间比之前有了较大的提示,
但是比03版本仍有不少差异
但是两个导出文件有3-4倍的差距,如果流量比较重要,或者网速比较重要可以用03,如果网速快,想提高服务器用03的导出



源码地址: 点击打开链接
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值