提交 0bdb64c5 编写于 作者: M Megvii Engine Team

ci(test): dump test time result to json file

GitOrigin-RevId: 0ed092a0e86cb336f1166459501f6fe5dcc7be31
上级 765c9d35
pytest==5.3.0 pytest==5.3.0
pytest-sphinx==0.2.2 pytest-sphinx>=0.2.2
pytest-json-report>=1.2.1
...@@ -76,7 +76,7 @@ setup_kwargs = dict( ...@@ -76,7 +76,7 @@ setup_kwargs = dict(
ext_modules=[PrecompiledExtesion('megengine._internal._mgb')], ext_modules=[PrecompiledExtesion('megengine._internal._mgb')],
install_requires=requires, install_requires=requires,
extras_require={ extras_require={
'dev': [*requires_style, *requires_test], 'dev': requires_style + requires_test,
'ci': requires_test, 'ci': requires_test,
}, },
cmdclass={'build_ext': build_ext}, cmdclass={'build_ext': build_ext},
......
# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License") # MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
# #
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved. # Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
...@@ -10,3 +9,26 @@ import os ...@@ -10,3 +9,26 @@ import os
import sys import sys
sys.path.append(os.path.join(os.path.dirname(__file__))) sys.path.append(os.path.join(os.path.dirname(__file__)))
def pytest_json_modifyreport(json_report):
events = []
timestamp = 0
for item in json_report["tests"]:
for stage in ["setup", "call", "teardown"]:
if stage in item:
events.append(
{
"name": item["nodeid"],
"ph": "X",
"ts": timestamp,
"dur": item[stage]["duration"] * 1e6,
"cat": stage,
"pid": stage,
"tid": item["nodeid"],
}
)
timestamp += events[-1]["dur"]
json_report["traceEvents"] = events
del json_report["collectors"]
del json_report["tests"]
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
pushd $(dirname "${BASH_SOURCE[0]}")/.. >/dev/null pushd $(dirname "${BASH_SOURCE[0]}")/.. >/dev/null
pytest -xv -m 'not internet' \ pytest -xv -m 'not internet' \
--json-report --json-report-file=time_python_test.json \
--ignore test/unit/module/test_pytorch.py \ --ignore test/unit/module/test_pytorch.py \
--ignore test/pytorch_comparison \ --ignore test/pytorch_comparison \
--ignore test/unit/hub/test_hub.py \ --ignore test/unit/hub/test_hub.py \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册