Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Shows total time taken to build the compiler #34614

Merged
merged 1 commit into from
Jul 3, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import argparse
import contextlib
import datetime
import hashlib
import os
import shutil
Expand All @@ -18,6 +19,8 @@
import tarfile
import tempfile

from time import time


def get(url, path, verbose=False):
sha_url = url + ".sha256"
Expand Down Expand Up @@ -118,6 +121,9 @@ def stage0_data(rust_root):
data[a] = b
return data

def format_build_time(duration):
return str(datetime.timedelta(seconds=int(duration)))

class RustBuild:
def download_stage0(self):
cache_dst = os.path.join(self.build_dir, "cache")
Expand Down Expand Up @@ -372,6 +378,8 @@ def main():
rb._rustc_channel, rb._rustc_date = data['rustc'].split('-', 1)
rb._cargo_channel, rb._cargo_date = data['cargo'].split('-', 1)

start_time = time()

# Fetch/build the bootstrap
rb.build = rb.build_triple()
rb.download_stage0()
Expand All @@ -390,5 +398,9 @@ def main():
env["BOOTSTRAP_PARENT_ID"] = str(os.getpid())
rb.run(args, env)

end_time = time()

print("Build completed in %s" % format_build_time(end_time - start_time))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: No need for a format string here, just use print("Build completed in in" + format_build_time(end_time - start_time))

Aside: Why doesn't this script have from __future__ import print_function? It would make printing simpler since one wouldn't have to perform manual string interpolation/concatenation everywhere).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like using formatting in place of concatenation. Seems cleaner imo 😊

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, concatenation is not ideal, IMHO the best option is simply print("...", timedelta) but that requires adding the __future__ import and that's probably out of scope. Perhaps I'll prepare a PR for that, since it seems #33036 was abandoned.


if __name__ == '__main__':
main()