1 # Copyright 2014 Google Inc. All rights reserved.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
18 def __init__(self, status_format, time_fn, size):
19 self.fmt = status_format
23 self.started_time = time_fn()
27 self._times.append(self.started_time)
30 if len(self._times) > self._size:
32 self._times.append(self._time())
35 # Too many statements pylint: disable=R0915
41 if c == '%' and p < end - 1:
44 elapsed = self._times[-1] - self._times[0]
46 out += '%5.1f' % ((len(self._times) - 1) / elapsed)
51 assert now >= self.started_time
52 out += '%-5.3f' % (now - self.started_time)
54 out += str(self.finished)
57 if now > self.started_time:
58 out += '%5.1f' % (self.finished * 1.0 /
59 (now - self.started_time))
64 out += '%5.1f' % (self.started * 100.0 / self.total)
68 out += str(self.started - self.finished)
70 out += str(self.started)
72 out += str(self.total)
74 out += str(self.total - self.finished)