Skip to content

Commit da099c2

Browse files
authored
Auto merge of #34614 - cynicaldevil:build-time, r=alexcrichton
Build: Shows total time taken to build the compiler Fixes #34600 Prints the total time taken to build rustc by executing `src/bootstrap/bootstrap.py`; also includes time taken to download `stage0` compiler and deps. r? @alexcrichton
2 parents d9e8a67 + 4dbe140 commit da099c2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/bootstrap/bootstrap.py

+12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import argparse
1212
import contextlib
13+
import datetime
1314
import hashlib
1415
import os
1516
import shutil
@@ -18,6 +19,8 @@
1819
import tarfile
1920
import tempfile
2021

22+
from time import time
23+
2124

2225
def get(url, path, verbose=False):
2326
sha_url = url + ".sha256"
@@ -118,6 +121,9 @@ def stage0_data(rust_root):
118121
data[a] = b
119122
return data
120123

124+
def format_build_time(duration):
125+
return str(datetime.timedelta(seconds=int(duration)))
126+
121127
class RustBuild:
122128
def download_stage0(self):
123129
cache_dst = os.path.join(self.build_dir, "cache")
@@ -372,6 +378,8 @@ def main():
372378
rb._rustc_channel, rb._rustc_date = data['rustc'].split('-', 1)
373379
rb._cargo_channel, rb._cargo_date = data['cargo'].split('-', 1)
374380

381+
start_time = time()
382+
375383
# Fetch/build the bootstrap
376384
rb.build = rb.build_triple()
377385
rb.download_stage0()
@@ -390,5 +398,9 @@ def main():
390398
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
391399
rb.run(args, env)
392400

401+
end_time = time()
402+
403+
print("Build completed in %s" % format_build_time(end_time - start_time))
404+
393405
if __name__ == '__main__':
394406
main()

0 commit comments

Comments
 (0)