grinder 测试HSF 协议
来源:互联网 发布:大脚 mac 编辑:程序博客网 时间:2024/05/17 02:21
1.脚本
package com.***.****.perf;
import com.***.****.client.GCException;
import com.***.****.client.domain.article.ArticleDTO;
import com.***.****.client.service.inner.ArticleReadService;
import com.***.****.hsfunit.HSFEasyStarter;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Author: wuche
* Date: 12-3-31
* Time: 下午4:32
*/
public class GetArticleByIdAPI {
private ArticleReadService articleReadService;
private static GetArticleByIdAPI _instance = null;
public static GetArticleByIdAPI getInstance() {
if (_instance == null)
_instance = new GetArticleByIdAPI();
return _instance;
}
private GetArticleByIdAPI() {
HSFEasyStarter.start();
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"itemcenter-client.perf.context.xml");
articleReadService = (ArticleReadService) context
.getBean("articleReadService");
}
public boolean getArticleById(long articleId) throws Exception{
articleId = 22104195L;
ArticleDTO result = null;
try {
result = articleReadService.getArticleById(articleId);
} catch (GCException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
if (null == result)
return false;
else
return true;
}
public static void main(String[] args) throws Exception {
long article = 22104195L;
GetArticleByIdAPI api = GetArticleByIdAPI.getInstance();
// for(int i=0 ;i<1000;i++){
System.out.println(api.getArticleById(article)?"TRUE":"FALSE");
// System.out.println(byIdApi.testGetArticleByCode(code)?"TRUE":"FALSE");
//
// }
}
import com.***.****.client.GCException;
import com.***.****.client.domain.article.ArticleDTO;
import com.***.****.client.service.inner.ArticleReadService;
import com.***.****.hsfunit.HSFEasyStarter;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Author: wuche
* Date: 12-3-31
* Time: 下午4:32
*/
public class GetArticleByIdAPI {
private ArticleReadService articleReadService;
private static GetArticleByIdAPI _instance = null;
public static GetArticleByIdAPI getInstance() {
if (_instance == null)
_instance = new GetArticleByIdAPI();
return _instance;
}
private GetArticleByIdAPI() {
HSFEasyStarter.start();
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"itemcenter-client.perf.context.xml");
articleReadService = (ArticleReadService) context
.getBean("articleReadService");
}
public boolean getArticleById(long articleId) throws Exception{
articleId = 22104195L;
ArticleDTO result = null;
try {
result = articleReadService.getArticleById(articleId);
} catch (GCException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
if (null == result)
return false;
else
return true;
}
public static void main(String[] args) throws Exception {
long article = 22104195L;
GetArticleByIdAPI api = GetArticleByIdAPI.getInstance();
// for(int i=0 ;i<1000;i++){
System.out.println(api.getArticleById(article)?"TRUE":"FALSE");
// System.out.println(byIdApi.testGetArticleByCode(code)?"TRUE":"FALSE");
//
// }
}
}
2.配置文件
<?xml version="1.0" encoding="GBK"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<!--<bean name="articleReadService" class="com.***.****.app.spring.util.HSFSpringConsumerBean" init-method="init">-->
<!--<property name="interfaceName" value="com.***.****.client.service.inner.ArticleReadService" />-->
<!--<property name="version" value="1.0.0.perf" />-->
<!--<property name="group" value="HSF" />-->
<!--</bean>-->
<bean name="itemReadService" class="***.****.app.spring.util.HSFSpringConsumerBean" init-method="init">
<property name="interfaceName" value="***.****.client.service.inner.ItemReadService" />
<property name="version" value="1.0.0.perf" />
<property name="group" value="HSF" />
</bean>
</beans>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-autowire="byName">
<!--<bean name="articleReadService" class="com.***.****.app.spring.util.HSFSpringConsumerBean" init-method="init">-->
<!--<property name="interfaceName" value="com.***.****.client.service.inner.ArticleReadService" />-->
<!--<property name="version" value="1.0.0.perf" />-->
<!--<property name="group" value="HSF" />-->
<!--</bean>-->
<bean name="itemReadService" class="***.****.app.spring.util.HSFSpringConsumerBean" init-method="init">
<property name="interfaceName" value="***.****.client.service.inner.ItemReadService" />
<property name="version" value="1.0.0.perf" />
<property name="group" value="HSF" />
</bean>
</beans>
3. 用 mvn install. 打包
4. 把打好的包和依赖的jar包放在grinder/lib目录下
5. 修改grinder.properties文件
grinder.jvm.classpath 增加/home/wuche/grinder-3.7.1/lib/app/itemcenter-perf-1.0.jar jar包
6.编辑grinder脚本
from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.script import Test
#import 这个测试类
from com.taobao.itemcenter.perf import UpdateItemQuantityAPI
from com.taobao.itemcenter.perf import UpdateItemQuantityAPI
#创建一个test,number+description
test1 = Test(1, "updateQuantity")
# Wrap the log() method with our Test and call the result logWrapper.
# Calls to logWrapper() will be recorded and forwarded on to the real
# log() method.
# Calls to logWrapper() will be recorded and forwarded on to the real
# log() method.
updateQuantity = test1.wrap(api.testUpdateItemQuantityForSubStockAtBuyAndSkuId)
# A TestRunner instance is created for each thread. It can be used to
# store thread-specific data.
class TestRunner:
# This method is called for every run.
def __call__(self):
grinder.statistics.delayReports = 1
#tid = grinder.getThreadNumber()
#itemId = 2791425
#skuId = 0
itemId = 6144
#itemId = 2791425
skuId = 4459
#if(0 == (tid % 3)):
# success = updateQuantityForSub(itemid)
#else:
success = updateQuantity(itemId,skuId)
#success = updateQuantity(itemId)
#grinder.sleep(1000)
if(not success):
grinder.statistics.forLastTest.success = 0
grinder.statistics.report()
grinder.statistics.delayReports = 0
# store thread-specific data.
class TestRunner:
# This method is called for every run.
def __call__(self):
grinder.statistics.delayReports = 1
#tid = grinder.getThreadNumber()
#itemId = 2791425
#skuId = 0
itemId = 6144
#itemId = 2791425
skuId = 4459
#if(0 == (tid % 3)):
# success = updateQuantityForSub(itemid)
#else:
success = updateQuantity(itemId,skuId)
#success = updateQuantity(itemId)
#grinder.sleep(1000)
if(not success):
grinder.statistics.forLastTest.success = 0
grinder.statistics.report()
grinder.statistics.delayReports = 0
- grinder 测试HSF 协议
- Grinder 性能测试
- Grinder测试脚本
- windows下grinder压力测试
- Grinder
- 使用性能测试工具Grinder做性能测试
- The Grinder
- grinder安装
- Grinder TCPProxy
- 比较Jmeter、Grinder和JAVA多线程本身压力测试所带来的性能开销
- HSF学习
- hsf入门
- hsf dubbo学习六--泛化,回声测试,上下文信息,隐式传参,异步调用,本地调用
- Grinder vs jmeter
- grinder 进程管理
- grinder脚本解析原理
- grinder进程管理分析
- Grinder支持SSL
- delphi高手突破之异常及错误处理
- 往joomla文章添加JS代码的方法
- 【编译原理】第一章 引论
- [备忘]收集的一些题集(更新中)
- python sqlite多线程编程
- grinder 测试HSF 协议
- IT研究员是产品经理中的工程师和工程师中的计算机专家——geek
- 单片机反汇编程序员居然沦落为电工!
- 关于DirectShow中摄像头的帧率设置
- <算法导论>第八章4 水壶(Kettle)
- Android sdcard相关内容
- android应用开发笔记---Activity和Intent
- HttpWatch工具简介及使用技巧
- CSS控制连续英文字母和数字强制换行