mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/43883 Check the result of GCC coverage in OSS is reasonable and ready to ship. The amount of executable lines are not the same between `gcc` and `clang` because of the following reasons: * Lines following are counted in `clang` but not in `gcc`: 1. empty line or line with only “{” or “}” 3. some comments are counted in clang but not in gcc 5. `#define ...` -- not supported by gcc according to official documentation * Besides, a statement that explains to more than one line will be counted as only one executable line in gcc, but several lines in clang ## Advantage of `gcc` coverage 1. Much faster - code coverage tool runtime is onle **4 min** (*ammazzzing!!*) by `gcc`, compared to **3 hours!!** by `clang`, to analyze all the tests' artifacts 2. Use less disk - `Clang`'s artifacts will take as large as 170G, but `GCC` is 980M Besides, also update `README.md`. Test Plan: Compare the result in OSS `clang` and OSS `gcc` with the same command: ``` python oss_coverage.py --run-only atest test_nn.py --interested-folder=aten ``` ---- ## GCC **Summary** > time: 0:15:45 summary percentage: 44.85% **Report and Log** [File Coverage Report](P140825162) [Line Coverage Report](P140825196) [Log](P140825385) ------ ## CLANG **Summary** > time: 0:21:35 summary percentage: 44.08% **Report and Log** [File Coverage Report](P140825845) [Line Coverage Report](P140825923) [Log](P140825950) ---------- # Run all tests ``` # run all tests and get coverage over Pytorch python oss_coverage.py ``` **Summary** > time: 1:27:20. ( time to run tests: 1:23:33) summary percentage: 56.62% **Report and Log** [File Coverage Report](P140837175) [Log](P140837121) Reviewed By: malfet Differential Revision: D23416772 fbshipit-source-id: a6810fa4d8199690f10bd0a4f58a42ab2a22182b
24 lines
657 B
Python
24 lines
657 B
Python
#!/usr/bin/env python
|
|
import time
|
|
|
|
from package.oss.cov_json import get_json_report
|
|
from package.oss.init import initialization
|
|
from package.tool.summarize_jsons import summarize_jsons
|
|
from package.util.setting import TestPlatform
|
|
|
|
|
|
def report_coverage() -> None:
|
|
start_time = time.time()
|
|
(options, test_list, interested_folders) = initialization()
|
|
# run cpp tests
|
|
get_json_report(test_list, options)
|
|
# collect coverage data from json profiles
|
|
if options.need_summary:
|
|
summarize_jsons(
|
|
test_list, interested_folders, [""], TestPlatform.OSS, start_time
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
report_coverage()
|