Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import contextlib | 5 import contextlib |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import shutil | 10 import shutil |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 signal.signal(signal.SIGALRM, _signal_callback) | 141 signal.signal(signal.SIGALRM, _signal_callback) |
| 142 if signal.alarm(seconds) != 0: | 142 if signal.alarm(seconds) != 0: |
| 143 raise TimeoutCollisionError( | 143 raise TimeoutCollisionError( |
| 144 'Discarding an alarm that was scheduled before.') | 144 'Discarding an alarm that was scheduled before.') |
| 145 yield | 145 yield |
| 146 finally: | 146 finally: |
| 147 signal.alarm(0) | 147 signal.alarm(0) |
| 148 if signal.getsignal(signal.SIGALRM) != _signal_callback: | 148 if signal.getsignal(signal.SIGALRM) != _signal_callback: |
| 149 raise TimeoutCollisionError('Looks like there is a signal.signal(signal.' | 149 raise TimeoutCollisionError('Looks like there is a signal.signal(signal.' |
| 150 'SIGALRM) made within the with statement.') | 150 'SIGALRM) made within the with statement.') |
| 151 | |
| 152 | |
| 153 @contextlib.contextmanager | |
| 154 def TimeMeasurement(measurement_name): | |
|
mattcary
2016/07/01 12:09:29
If this isn't used in this patch, make a separate
gabadie
2016/07/01 14:10:26
Done.
| |
| 155 start = time.time() | |
| 156 yield | |
| 157 end = time.time() | |
| 158 logging.info('%s: %ds', measurement_name, (end - start)) | |
| OLD | NEW |