Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
doujutun3207
flink
提交
7265d81f
F
flink
项目概览
doujutun3207
/
flink
与 Fork 源项目一致
从无法访问的项目Fork
通知
24
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
flink
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7265d81f
编写于
10月 26, 2015
作者:
G
gallenvara
提交者:
Fabian Hueske
10月 26, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FLINK-2919] Port FieldAccessMinibenchmark to JMH.
This closes #1300
上级
e5ee55bd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
65 addition
and
45 deletion
+65
-45
flink-benchmark/src/test/java/org/apache/flink/benchmark/api/java/typeutils/runtime/FieldAccessMinibenchmark.java
.../api/java/typeutils/runtime/FieldAccessMinibenchmark.java
+65
-45
未找到文件。
flink-
java/src/test/java/org/apache/flin
k/api/java/typeutils/runtime/FieldAccessMinibenchmark.java
→
flink-
benchmark/src/test/java/org/apache/flink/benchmar
k/api/java/typeutils/runtime/FieldAccessMinibenchmark.java
浏览文件 @
7265d81f
...
...
@@ -15,14 +15,27 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.flink.api.java.typeutils.runtime
;
package
org.apache.flink.benchmark.api.java.typeutils.runtime
;
import
org.openjdk.jmh.annotations.*
;
import
org.openjdk.jmh.results.RunResult
;
import
org.openjdk.jmh.runner.Runner
;
import
org.openjdk.jmh.runner.RunnerException
;
import
org.openjdk.jmh.runner.options.Options
;
import
org.openjdk.jmh.runner.options.OptionsBuilder
;
import
java.lang.management.ManagementFactory
;
import
java.lang.management.RuntimeMXBean
;
import
java.lang.reflect.Field
;
import
java.util.Collection
;
import
java.util.concurrent.TimeUnit
;
@State
(
Scope
.
Thread
)
@BenchmarkMode
(
Mode
.
AverageTime
)
@OutputTimeUnit
(
TimeUnit
.
MILLISECONDS
)
public
class
FieldAccessMinibenchmark
{
private
final
long
RUNS
=
1000000000L
;
static
Field
wordDescField
;
static
Field
wordField
;
static
{
...
...
@@ -34,6 +47,17 @@ public class FieldAccessMinibenchmark {
}
}
@Setup
public
void
warmUp
()
throws
NoSuchFieldException
,
IllegalAccessException
{
WC
word0
=
new
WC
(
14
,
"Hallo"
);
WC
word1
=
new
WC
(
3
,
"Hola"
);
for
(
long
i
=
0
;
i
<
100000000
;
i
++)
{
compareCodeGenPublicFields
(
word0
,
word1
);
compareCodeGenMethods
(
word0
,
word1
);
compareReflective
(
word0
,
word1
);
}
}
public
static
class
ComplexWordDescriptor
{
public
String
word
;
...
...
@@ -80,71 +104,67 @@ public class FieldAccessMinibenchmark {
return
word2cmp1
.
compareTo
(
word2cmp2
);
}
/**
* results on Core i7 2600k
*
*
* warming up Code gen 5019 Reflection 20364 Factor = 4.057382
*/
public
static
void
main
(
String
[]
args
)
throws
NoSuchFieldException
,
SecurityException
,
IllegalArgumentException
,
IllegalAccessException
{
final
long
RUNS
=
1000000000L
;
final
RuntimeMXBean
bean
=
ManagementFactory
.
getRuntimeMXBean
();
String
jvm
=
bean
.
getVmName
()
+
" - "
+
bean
.
getVmVendor
()
+
" - "
+
bean
.
getSpecVersion
()
+
'/'
+
bean
.
getVmVersion
();
System
.
err
.
println
(
"Jvm info : "
+
jvm
);
@Benchmark
public
void
codeGenPublicFields
()
throws
NoSuchFieldException
{
WC
word0
=
new
WC
(
14
,
"Hallo"
);
WC
word1
=
new
WC
(
3
,
"Hola"
);
System
.
err
.
println
(
"warming up"
);
for
(
long
i
=
0
;
i
<
100000000
;
i
++)
{
compareCodeGenPublicFields
(
word0
,
word1
);
compareCodeGenMethods
(
word0
,
word1
);
compareReflective
(
word0
,
word1
);
}
System
.
err
.
println
(
"Code gen public fields"
);
long
startTime
=
System
.
currentTimeMillis
();
for
(
long
i
=
0
;
i
<
RUNS
;
i
++)
{
int
a
=
compareCodeGenPublicFields
(
word0
,
word1
);
if
(
a
==
0
)
{
System
.
err
.
println
(
"hah"
);
}
}
long
stopTime
=
System
.
currentTimeMillis
();
long
elapsedTimeGen
=
stopTime
-
startTime
;
System
.
err
.
println
(
elapsedTimeGen
);
}
System
.
err
.
println
(
"Code gen methods"
);
startTime
=
System
.
currentTimeMillis
();
@Benchmark
public
void
codeGenMethods
()
throws
NoSuchFieldException
{
WC
word0
=
new
WC
(
14
,
"Hallo"
);
WC
word1
=
new
WC
(
3
,
"Hola"
);
for
(
long
i
=
0
;
i
<
RUNS
;
i
++)
{
int
a
=
compareCodeGenPublicFields
(
word0
,
word1
);
if
(
a
==
0
)
{
System
.
err
.
println
(
"hah"
);
}
}
stopTime
=
System
.
currentTimeMillis
();
long
elapsedTimeGenMethods
=
stopTime
-
startTime
;
System
.
err
.
println
(
elapsedTimeGenMethods
);
System
.
err
.
println
(
"Reflection"
);
}
startTime
=
System
.
currentTimeMillis
();
@Benchmark
public
void
reflection
()
throws
NoSuchFieldException
,
IllegalAccessException
{
WC
word0
=
new
WC
(
14
,
"Hallo"
);
WC
word1
=
new
WC
(
3
,
"Hola"
);
for
(
long
i
=
0
;
i
<
RUNS
;
i
++)
{
int
a
=
compareReflective
(
word0
,
word1
);
if
(
a
==
0
)
{
System
.
err
.
println
(
"hah"
);
}
}
stopTime
=
System
.
currentTimeMillis
();
long
elapsedTimeRef
=
stopTime
-
startTime
;
System
.
err
.
println
(
elapsedTimeRef
);
System
.
err
.
println
(
"Factor vs public = "
+
(
elapsedTimeRef
/
(
float
)
elapsedTimeGen
));
System
.
err
.
println
(
"Factor vs methods = "
+
(
elapsedTimeRef
/
(
float
)
elapsedTimeGenMethods
));
}
/**
* results on Core i7 2600k
*
*
* warming up Code gen 5019 Reflection 20364 Factor = 4.057382
*/
public
static
void
main
(
String
[]
args
)
throws
RunnerException
{
Options
opt
=
new
OptionsBuilder
()
.
include
(
FieldAccessMinibenchmark
.
class
.
getSimpleName
())
.
warmupIterations
(
2
)
.
measurementIterations
(
2
)
.
forks
(
1
)
.
build
();
Collection
<
RunResult
>
results
=
new
Runner
(
opt
).
run
();
double
[]
score
=
new
double
[
3
];
int
count
=
0
;
final
RuntimeMXBean
bean
=
ManagementFactory
.
getRuntimeMXBean
();
String
jvm
=
bean
.
getVmName
()
+
" - "
+
bean
.
getVmVendor
()
+
" - "
+
bean
.
getSpecVersion
()
+
'/'
+
bean
.
getVmVersion
();
System
.
err
.
println
(
"Jvm info : "
+
jvm
);
for
(
RunResult
r
:
results
)
{
score
[
count
++]
=
r
.
getPrimaryResult
().
getScore
();
}
System
.
err
.
println
(
"Factor vs public = "
+
score
[
2
]
/
score
[
1
]);
System
.
err
.
println
(
"Factor vs methods = "
+
score
[
2
]
/
score
[
0
]);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录