Base64实现测试,不要太相信apache-common的性能
针对三种Base64实现:
* 自已实现的
* JDK8的java.util.Base64
* apache-common的org.apache.commons.codec.binary.Base64
/**
* 用于命令行调用
*
* @throws Exception
*/
public static void main(String[] args) throws Exception { byte[] binaryData = "这是一个小小的测试 this is a test only".getBytes(); long t1 = System.currentTimeMillis(); for (int i = 0; i < 10000 * 1000; i++)
Base64.decode(Base64.encode(binaryData)); long t2 = System.currentTimeMillis(); Encoder encoder = java.util.Base64.getEncoder();
Decoder decoder = java.util.Base64.getDecoder();
for (int i = 0; i < 10000 * 1000; i++)
decoder.decode(encoder.encodeToString(binaryData)); long t3 = System.currentTimeMillis(); for (int i = 0; i < 10000 * 1000; i++)
org.apache.commons.codec.binary.Base64.decodeBase64(org.apache.commons.codec.binary.Base64.encodeBase64String(binaryData)); long t4 = System.currentTimeMillis(); System.out.println("t2-t1:"+(t2-t1));
System.out.println("t3-t2:"+(t3-t2));
System.out.println("t4-t3:"+(t4-t3));
}
测试结果:
t2-t1:7871 #自己实现的
t3-t2:2820 #JDK8自带的
t4-t3:25142 #apache-common的
不要太相信apache-common的性能。
Base64实现测试,不要太相信apache-common的性能的更多相关文章
- Apache Common DbUtils
前段时间使用了Apache Common DbUtils这个工具,在此留个印,以备不时查看.大家都知道现在市面上的数据库访问层的框架很多,当然很多都是包含了OR-Mapping工作步骤的 例如大家常用 ...
- apache common pool2原理与实战
完整源码,请帮我点个star哦! 原文地址为https://www.cnblogs.com/haixiang/p/14783955.html,转载请注明出处! 简介 对象池顾名思义就是存放对象的池,与 ...
- apache common包下的StringUtils的join方法
apache common包下的StringUtils的join方法: 关键字:java string array join public static String join(Iterator it ...
- org.apache.common.io-FileUtils详解
org.apache.common.io---FileUtils详解 getTempDirectoryPath():返回临时目录路径; public static String getTempDire ...
- Common lang一些边界方法总结(好记性不如烂笔头,需要慢慢积累).一定要利用好现有的轮子,例如Apache common与Google Guava
好记性真是不如烂笔头啊!!!! 如下代码: List<String> list = new ArrayList<String>(); list.add("1" ...
- WEB文件上传之apache common upload使用(一)
文件上传一个经常用到的功能,它有许多中实现的方案. 页面表单 + RFC1897规范 + http协议上传 页面控件(flash/html5/activeX/applet) + RFC1897规范 + ...
- Android中使用Apache common ftp进行下载文件
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/birdsaction/article/details/36379201 在Android使用ftp下 ...
- iOS测试-如何指标量化app耗电量和性能XCTest Metrics
对于app端的专项测试,Android端我们可以用adb或者一些三方工具进行(例如itest)进行实时的性能监控,iOS端的话也可以用用一些三方的工具,但是需要嵌入到我们的项目当中,今天来介绍下Xco ...
- Apache common pool2 对象池
对象池的容器:包含一个指定数量的对象.从池中取出一个对象时,它就不存在池中,直到它被放回.在池中的对象有生命周期:创建,验证,销毁,对象池有助于更好地管理可用资源,防止JVM内部大量临时小对象,频繁触 ...
随机推荐
- 将String转化为Long,并将Long转化为Date 分类: B1_JAVA 2014-06-30 16:23 1249人阅读 评论(0) 收藏
package org.ljh.test.javaee; import java.text.SimpleDateFormat; import java.util.Date; public class ...
- hibernate级联保存问题
异常:org.hibernate.TransientObjectException: object references an unsaved transient instance 解决方法: XML ...
- 浏览器jsp、html之间的关系
浏览器html.jsp之间的关系 1.HTML能直接通过浏览器打开,而JSP仅仅能公布到Tomcatserver才干打开. 2.HTML中不能嵌套Java代码,而JSP中能够嵌套Java代码: 3.H ...
- ART、JIT、AOT、Dalvik之间有什么关系?
JIT与Dalvik JIT是"Just In Time Compiler"的缩写,就是"即时编译技术",与Dalvik虚拟机相关. 怎么理解这句话呢?这要从A ...
- 【第400篇题解纪念2016年10月28日】【28.10%】【codeforces 617E】XOR and Favorite Number
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- hadoop 3.x 回收站
使用回收站最主要是为了给误删文件的你留条后路 打开core-site.xml添加以下配置 <!--回收站保存文件时间--> <property> <name>fs. ...
- android 如何创建配置文件和读配置文件
因为一些配置信息,多处用到的.且以后可能变更的,我想写个.prorperties配置文件给管理起来.在studio中新建一个Assets文件-->新建一个file文件类型为properties文 ...
- Starting MySQL.. ERROR! The server quit without updating PID file (/usr/local/mysql/data/vm10-0-0-19
输入:service mysqld start 报错: Starting MySQL.. ERROR! The server quit without updating PID file (/usr/ ...
- Hexo里如何添加广告
前期先用Hexo做个人网站,模板可以用https://github.com/828768/maupassant-hexo,关于如何加入广告,可以看一下https://sobaigu.com/hexo- ...
- Mobile Push Notification
In one embodiment, a method includes sending to a mobile client computing device a first notificatio ...