Created
November 1, 2024 02:30
-
-
Save faithandbrave/33020265ecbbfef182f05c2c367a6747 to your computer and use it in GitHub Desktop.
リンクチェックにかかった時間を出力するパッチ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git forkSrcPrefix/.github/workflows/script/link_check.py forkDstPrefix/.github/workflows/script/link_check.py | |
| index 30c9286ddda25070b410322cbe047aaf6ef5071e..1943400b495f9f0d21b90335fbefe6255a4b6beb 100644 | |
| --- forkSrcPrefix/.github/workflows/script/link_check.py | |
| +++ forkDstPrefix/.github/workflows/script/link_check.py | |
| @@ -8,6 +8,7 @@ import requests | |
| import sys | |
| import time | |
| import random | |
| +import collections | |
| urllib3.disable_warnings() | |
| @@ -165,15 +166,30 @@ if __name__ == '__main__': | |
| print("{} href {} not found.".format(p, link), file=sys.stderr) | |
| found_error = True | |
| + time_dict = collections.OrderedDict() | |
| if args.check_outer_link: | |
| if len(args.url) > 0: | |
| outer_link_dict[args.url] = "" | |
| for link, from_list in outer_link_dict.items(): | |
| + start = time.time() | |
| exists, reason = check_url(link) | |
| + end = time.time() | |
| + time_dict[link] = end - start | |
| if not exists: | |
| print("URL {} not found. {} from:{}".format(link, reason, from_list), file=sys.stderr) | |
| found_error = True | |
| + total_time = 0.0 | |
| + sorted_time_dict = collections.OrderedDict( | |
| + sorted(time_dict.items(), key=lambda x: x[0]) | |
| + ) | |
| + for link, elapsed in sorted_time_dict.items(): | |
| + print("{}: time {}".format(link, elapsed)) | |
| + total_time += elapsed | |
| + | |
| + if len(time_dict) > 0: | |
| + print("total time:{}", total_time) | |
| + | |
| if found_error: | |
| sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment