Mercurial > hg
changeset 40524:25732c5678bc
ui: wrap whole _write() block with timeblockedsection
I think the cost of color labeling is negligible compared to the I/O
syscalls. Let's simply wrap the whole write() function so that we can
eliminate _write() and _write_err() in later changeset.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 03 Nov 2018 17:47:23 +0900 |
parents | 0c7b2035a604 |
children | 433189151d5d |
files | mercurial/ui.py |
diffstat | 1 files changed, 6 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Sat Nov 03 17:43:57 2018 +0900 +++ b/mercurial/ui.py Sat Nov 03 17:47:23 2018 +0900 @@ -952,6 +952,9 @@ def _writenobuf(self, write, *args, **opts): self._progclear() msg = b''.join(args) + + # opencode timeblockedsection because this is a critical path + starttime = util.timer() try: if self._colormode == 'win32': # windows color printing is its own can of crab, defer to @@ -963,18 +966,14 @@ msg = self.label(msg, label) write(msg) finally: - pass + self._blockedtimes['stdio_blocked'] += \ + (util.timer() - starttime) * 1000 def _write(self, data): - # opencode timeblockedsection because this is a critical path - starttime = util.timer() try: self.fout.write(data) except IOError as err: raise error.StdioError(err) - finally: - self._blockedtimes['stdio_blocked'] += \ - (util.timer() - starttime) * 1000 def write_err(self, *args, **opts): if self._bufferstates and self._bufferstates[-1][0]: @@ -984,7 +983,7 @@ def _write_err(self, data): try: - with self.timeblockedsection('stdio'): + if True: if not getattr(self.fout, 'closed', False): self.fout.flush() self.ferr.write(data)