1 Star 0 Fork 259

SuperCoder/AutoLoadCache

forked from qiujiayu/AutoLoadCache 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
FST.java 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
qiujiayu 提交于 2020-03-09 23:33 +08:00 . remove @author 
package com.test;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import org.nustaq.serialization.FSTConfiguration;
import com.test.hessian.MyTO;
/**
*
* TODO
*
*/
public class FST {
private static final FSTConfiguration conf=FSTConfiguration.getDefaultConfiguration();
static {
// conf.setCrossPlatform(false);
}
public static void main(String[] args) throws Exception {
long start=System.currentTimeMillis();
MyTO to=new MyTO();
to.setId("111");
List<String> list=new ArrayList<String>();
list.add("111");
list.add("222");
to.setList(list);
byte[] data=null;
for(int i=0; i < 1000; i++) {
data=write(to);
}
long end=System.currentTimeMillis();
System.out.println("write:" + (end - start));
System.out.println("size:" + data.length);
start=System.currentTimeMillis();
for(int i=0; i < 1000; i++) {
read(data);
}
end=System.currentTimeMillis();
System.out.println("read:" + (end - start));
Simple simple=new Simple();
simple.setAge(10);
simple.setName("test");
simple.setSex(1);
SimpleWrapper wrapper=new SimpleWrapper();
wrapper.setCacheObject(simple);
wrapper.setLastLoadTime(System.currentTimeMillis());
data=write(wrapper);
SimpleWrapper t=(SimpleWrapper)read(data);
System.out.println(t.getCacheObject().getName());
}
private static byte[] write(Object obj) throws Exception {
byte barray[]=conf.asByteArray(obj);
return barray;
}
private static Object read(byte[] data) throws Exception {
return conf.asObject(data);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/SuperCoderMan521/AutoLoadCache.git
git@gitee.com:SuperCoderMan521/AutoLoadCache.git
SuperCoderMan521
AutoLoadCache
AutoLoadCache
master

搜索帮助