Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Forever310
druid
提交
2145f78f
D
druid
项目概览
Forever310
/
druid
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
druid
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2145f78f
编写于
12月 04, 2012
作者:
X
xvrl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add memcached cache benchmarking code
上级
1083ed9c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
107 addition
and
0 deletion
+107
-0
client/pom.xml
client/pom.xml
+5
-0
client/src/test/java/com/metamx/druid/client/cache/MemcachedCacheBrokerBenchmark.java
...amx/druid/client/cache/MemcachedCacheBrokerBenchmark.java
+95
-0
pom.xml
pom.xml
+7
-0
未找到文件。
client/pom.xml
浏览文件 @
2145f78f
...
...
@@ -187,6 +187,11 @@
<artifactId>
easymock
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.google.caliper
</groupId>
<artifactId>
caliper
</artifactId>
<scope>
test
</scope>
</dependency>
</dependencies>
<build>
...
...
client/src/test/java/com/metamx/druid/client/cache/MemcachedCacheBrokerBenchmark.java
0 → 100644
浏览文件 @
2145f78f
package
com.metamx.druid.client.cache
;
import
com.google.caliper.Param
;
import
com.google.caliper.Runner
;
import
com.google.caliper.SimpleBenchmark
;
import
java.util.Random
;
import
java.util.concurrent.TimeUnit
;
public
class
MemcachedCacheBrokerBenchmark
extends
SimpleBenchmark
{
private
static
final
String
BASE_KEY
=
"test_2012-11-26T00:00:00.000Z_2012-11-27T00:00:00.000Z_2012-11-27T04:11:25.979Z_"
;
private
MemcachedCacheBroker
broker
;
private
Cache
cache
;
private
static
byte
[]
randBytes
;
// object size in kB
@Param
({
"1"
,
"5"
,
"10"
,
"40"
})
int
objectSize
;
@Param
({
"100"
,
"1000"
})
int
objectCount
;
@Override
protected
void
setUp
()
throws
Exception
{
broker
=
MemcachedCacheBroker
.
create
(
new
MemcachedCacheBrokerConfig
()
{
@Override
public
int
getExpiration
()
{
// 1 year
return
3600
*
24
*
365
;
}
@Override
public
int
getTimeout
()
{
// 500 milliseconds
return
500
;
}
@Override
public
String
getHosts
()
{
return
"localhost:11211"
;
}
@Override
public
int
getMaxObjectSize
()
{
// 50 MB
return
50
*
1024
*
1024
;
}
}
);
cache
=
broker
.
provideCache
(
"default"
);
randBytes
=
new
byte
[
objectSize
*
1024
];
new
Random
(
0
).
nextBytes
(
randBytes
);
}
@Override
protected
void
tearDown
()
throws
Exception
{
broker
.
getClient
().
flush
();
broker
.
getClient
().
shutdown
();
}
public
void
timePutObjects
(
int
reps
)
{
for
(
int
i
=
0
;
i
<
reps
;
++
i
)
{
for
(
int
k
=
0
;
k
<
objectCount
;
++
k
)
{
String
key
=
BASE_KEY
+
i
;
cache
.
put
(
key
.
getBytes
(),
randBytes
);
}
broker
.
getClient
().
waitForQueues
(
1
,
TimeUnit
.
HOURS
);
}
}
public
byte
[]
timeGetObject
(
int
reps
)
{
byte
[]
bytes
=
null
;
for
(
int
i
=
0
;
i
<
reps
;
i
++)
{
for
(
int
k
=
0
;
k
<
objectCount
;
++
k
)
{
String
key
=
BASE_KEY
+
i
;
bytes
=
cache
.
get
(
key
.
getBytes
());
}
}
return
bytes
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Runner
.
main
(
MemcachedCacheBrokerBenchmark
.
class
,
args
);
}
}
pom.xml
浏览文件 @
2145f78f
...
...
@@ -279,6 +279,13 @@
<version>
4.8.1
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.google.caliper
</groupId>
<artifactId>
caliper
</artifactId>
<version>
0.5-rc1
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录