【迁移2015-09-15 13:38】Kestrel(三)
2018-08-10 10:03
197 查看
Test
新建一个spring配置文件applicationContext.xml,导入之前的
- kestrel.properties - kestrel.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:property-placeholder location="classpath:kestrel.properties" /> <import resource="kestrel.xml" /> </beans>
新建JUnit测试
import static junit.framework.Assert.*; import net.rubyeye.xmemcached.MemcachedClient; import org.junit.Before; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.util.StopWatch; /** * Kestrel 测试 * */ public class KestrelTest { private final static String QUEUE_NAME = "KQ"; private ApplicationContext app; private MemcachedClient memcachedClient; private static final int COUNT = 5000; /** * @throws Exception */ @Before public void before() throws Exception { app = new ClassPathXmlApplicationContext("spring/applicationContext.xml"); memcachedClient = (MemcachedClient) app.getBean("memcachedClient"); } /** * 发包测试 */ @Test public void send() { StopWatch stopWatch = new StopWatch("send"); stopWatch.start("set"); memcachedClient.setOpTimeout(5000L); for (int i = 0; i < COUNT; i++) { try { memcachedClient.set(QUEUE_NAME, 0, "http://"+i+"_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo_twentwo"); } catch (Exception e) { fail(e.getMessage()); e.printStackTrace(); } } stopWatch.stop(); System.out.println(stopWatch.prettyPrint()); } /** * 收包测试 */ @Test public void receive() { String value; StopWatch stopWatch = new StopWatch("receive"); stopWatch.start("get"); try { while (true) { memcachedClient.setOpTimeout(5000L); value = (String) memcachedClient.get(QUEUE_NAME); if (value == null) { break; } System.out.println(value); } } catch (Exception e) { fail(e.getMessage()); e.printStackTrace(); } stopWatch.stop(); System.out.println(stopWatch.prettyPrint()); } }
测试环境
- kestrel server服务环境,本地虚拟机,centOS6.6,只分配了650M内存,1核CPU - jdk7,单线程,单client - 消息个数5000,消息长度约256
发送测试结果
StopWatch 'send': running time (millis) = 2248 ----------------------------------------- ms % Task name ----------------------------------------- 02248 100% set
接收测试结果
StopWatch 'receive': running time (millis) = 2896 ----------------------------------------- ms % Task name ----------------------------------------- 02896 100% get
相关文章推荐
- 【迁移2015-09-08 16:03】Kestrel(二)
- 【迁移2015-09-07 14:22】Kestrel(一)
- 【迁移2015-09-15 13:40】HTTPSQS(一)
- 如何把Composer镜像迁移到Laravel China 维护的镜像?
- 迁移学习 transfer learning
- QEMU-KVM虚机动态迁移原理
- Perl访问MSSQL并迁移到MySQL数据库脚本实例
- 升级到 exchange 2010 sp1 迁移邮箱很慢 的解决办法
- Entity Framework学习-实体框架中的code-first迁移
- Windows 故障转移+Hyper-V 虚机自动迁移高 可用
- Oracle二三事之 数据迁移注意事项
- QT4迁移QT5注意事项
- 迁移Mysql数据库到Azure上的SQL database
- 如何将数据库从SQL Server迁移到MySQL
- Django中model使用迁移(migrate)部分数据库会遇到的坑
- [CCIE笔记]IPv6——IPv4到IPv6的迁移
- git库迁移到本地中进行局域网内开发
- Linux oracle单机停机迁移数据库(目标不安装oracle软件的情况)
- ArcGIS 10 SDE for ORACLE ---迁移 (2)
- 博客迁移通知