Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_38905368
tensorflow
提交
a128dee2
T
tensorflow
项目概览
qq_38905368
/
tensorflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tensorflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a128dee2
编写于
4月 11, 2016
作者:
E
Eugene Brevdo
提交者:
TensorFlower Gardener
4月 11, 2016
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clean up benchmark.py after previous modifications and add unit test.
Change: 119549296
上级
45b208d1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
22 deletion
+27
-22
tensorflow/python/kernel_tests/benchmark_test.py
tensorflow/python/kernel_tests/benchmark_test.py
+13
-0
tensorflow/python/platform/benchmark.py
tensorflow/python/platform/benchmark.py
+14
-22
未找到文件。
tensorflow/python/kernel_tests/benchmark_test.py
浏览文件 @
a128dee2
...
...
@@ -103,6 +103,19 @@ class BenchmarkTest(tf.test.TestCase):
self
.
assertTrue
(
_ran_somebenchmark_2
[
0
])
self
.
assertFalse
(
_ran_somebenchmark_but_shouldnt
[
0
])
_ran_somebenchmark_1
[
0
]
=
False
_ran_somebenchmark_2
[
0
]
=
False
_ran_somebenchmark_but_shouldnt
[
0
]
=
False
# Test running a specific method of SomeRandomBenchmark
if
benchmark
.
TEST_REPORTER_TEST_ENV
in
os
.
environ
:
del
os
.
environ
[
benchmark
.
TEST_REPORTER_TEST_ENV
]
benchmark
.
_run_benchmarks
(
"SomeRandom.*1$"
)
self
.
assertTrue
(
_ran_somebenchmark_1
[
0
])
self
.
assertFalse
(
_ran_somebenchmark_2
[
0
])
self
.
assertFalse
(
_ran_somebenchmark_but_shouldnt
[
0
])
def
testReportingBenchmark
(
self
):
tempdir
=
tf
.
test
.
get_temp_dir
()
try
:
...
...
tensorflow/python/platform/benchmark.py
浏览文件 @
a128dee2
...
...
@@ -245,27 +245,13 @@ class TensorFlowBenchmark(Benchmark):
name
=
name
)
def
_run_specific_benchmark
(
benchmark_class
):
benchmark
=
benchmark_class
()
attrs
=
dir
(
benchmark
)
# Only run methods of this class whose names start with "benchmark"
for
attr
in
attrs
:
if
not
attr
.
startswith
(
"benchmark"
):
continue
benchmark_fn
=
getattr
(
benchmark
,
attr
)
if
not
callable
(
benchmark_fn
):
continue
# Call this benchmark method
benchmark_fn
()
def
_run_benchmarks
(
regex
):
"""Run benchmarks that match regex `regex`.
This function goes through the global benchmark registry, and matches
benchmark
**classe names** of the form "module.name.BenchmarkClass" to
the given regex. If a class matches, all of its benchmark methods
are
run.
benchmark
class and method names of the form
`module.name.BenchmarkClass.benchmarkMethod` to the given regex.
If a method matches, it is
run.
Args:
regex: The string regular expression to match Benchmark classes against.
...
...
@@ -275,18 +261,24 @@ def _run_benchmarks(regex):
# Match benchmarks in registry against regex
for
benchmark
in
registry
:
benchmark_name
=
"%s.%s"
%
(
benchmark
.
__module__
,
benchmark
.
__name__
)
attrs
=
dir
(
benchmark
)
# Don't instantiate the benchmark class unless necessary
benchmark_instance
=
None
benchmark_class
=
benchmark
()
attrs
=
dir
(
benchmark_class
)
for
attr
in
attrs
:
if
not
attr
.
startswith
(
"benchmark"
):
continue
benchmark_fn
=
getattr
(
benchmark_class
,
attr
)
if
not
callable
(
benchmark_fn
):
candidate_benchmark_fn
=
getattr
(
benchmark
,
attr
)
if
not
callable
(
candidate_
benchmark_fn
):
continue
full_benchmark_name
=
"%s.%s"
%
(
benchmark_name
,
attr
)
if
regex
==
"all"
or
re
.
search
(
regex
,
full_benchmark_name
):
benchmark_fn
()
# Instantiate the class if it hasn't been instantiated
benchmark_instance
=
benchmark_instance
or
benchmark
()
# Get the method tied to the class
instance_benchmark_fn
=
getattr
(
benchmark_instance
,
attr
)
# Call the instance method
instance_benchmark_fn
()
def
benchmarks_main
(
true_main
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录