28
28
import json
29
29
import logging
30
30
import logging .handlers
31
- from functools import total_ordering
31
+ from functools import total_ordering , cache
32
32
from os import readlink
33
33
import platform
34
34
import re
@@ -702,6 +702,7 @@ def translation_branch(self):
702
702
def build (self ):
703
703
"""Build this version/language doc."""
704
704
logging .info ("Build start." )
705
+ start_time = perf_counter ()
705
706
sphinxopts = list (self .language .sphinxopts )
706
707
sphinxopts .extend (["-q" ])
707
708
if self .language .tag != "en" :
@@ -778,7 +779,9 @@ def is_mac():
778
779
setup_switchers (
779
780
self .versions , self .languages , self .checkout / "Doc" / "build" / "html"
780
781
)
781
- logging .info ("Build done." )
782
+ logging .info (
783
+ "Build done (%.1f minutes)." , format_seconds (perf_counter () - start_time )
784
+ )
782
785
783
786
def build_venv (self ):
784
787
"""Build a venv for the specific Python version.
@@ -800,6 +803,7 @@ def build_venv(self):
800
803
def copy_build_to_webroot (self ):
801
804
"""Copy a given build to the appropriate webroot with appropriate rights."""
802
805
logging .info ("Publishing start." )
806
+ start_time = perf_counter ()
803
807
self .www_root .mkdir (parents = True , exist_ok = True )
804
808
if self .language .tag == "en" :
805
809
target = self .www_root / self .version .name
@@ -912,7 +916,10 @@ def copy_build_to_webroot(self):
912
916
purge (* prefixes )
913
917
for prefix in prefixes :
914
918
purge (* [prefix + p for p in changed ])
915
- logging .info ("Publishing done" )
919
+ logging .info (
920
+ "Publishing done (%.1f minutes)." ,
921
+ format_seconds (perf_counter () - start_time ),
922
+ )
916
923
917
924
def should_rebuild (self ):
918
925
state = self .load_state ()
@@ -1147,6 +1154,15 @@ def build_docs(args) -> bool:
1147
1154
return all_built_successfully
1148
1155
1149
1156
1157
+ @cache
1158
+ def format_seconds (seconds : float ) -> str :
1159
+ minutes = int (seconds // 60 )
1160
+ seconds = round (seconds % 60 )
1161
+ if minutes == 0 :
1162
+ return f"{ seconds } s"
1163
+ return f"{ minutes } m{ seconds } s"
1164
+
1165
+
1150
1166
def main ():
1151
1167
"""Script entry point."""
1152
1168
args = parse_args ()
0 commit comments