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,7 @@ 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 ("Build done (%s)." , format_seconds ( perf_counter () - start_time ) )
782
783
783
784
def build_venv (self ):
784
785
"""Build a venv for the specific Python version.
@@ -800,6 +801,7 @@ def build_venv(self):
800
801
def copy_build_to_webroot (self ):
801
802
"""Copy a given build to the appropriate webroot with appropriate rights."""
802
803
logging .info ("Publishing start." )
804
+ start_time = perf_counter ()
803
805
self .www_root .mkdir (parents = True , exist_ok = True )
804
806
if self .language .tag == "en" :
805
807
target = self .www_root / self .version .name
@@ -912,7 +914,9 @@ def copy_build_to_webroot(self):
912
914
purge (* prefixes )
913
915
for prefix in prefixes :
914
916
purge (* [prefix + p for p in changed ])
915
- logging .info ("Publishing done" )
917
+ logging .info (
918
+ "Publishing done (%s)." , format_seconds (perf_counter () - start_time )
919
+ )
916
920
917
921
def should_rebuild (self ):
918
922
state = self .load_state ()
@@ -1147,6 +1151,21 @@ def build_docs(args) -> bool:
1147
1151
return all_built_successfully
1148
1152
1149
1153
1154
+ @cache
1155
+ def format_seconds (seconds : float ) -> str :
1156
+ hours , remainder = divmod (seconds , 3600 )
1157
+ minutes , seconds = divmod (remainder , 60 )
1158
+ seconds = round (seconds )
1159
+
1160
+ match (hours , minutes , seconds ):
1161
+ case 0 , 0 , s :
1162
+ return f"{ s } s"
1163
+ case 0 , m , s :
1164
+ return f"{ m } m { s } s"
1165
+ case h , m , s :
1166
+ return f"{ h } h { m } m { s } s"
1167
+
1168
+
1150
1169
def main ():
1151
1170
"""Script entry point."""
1152
1171
args = parse_args ()
0 commit comments