MCPcopy
hub / github.com/rueckstiess/mtools / duration

Method duration

mtools/util/logevent.py:193–225  ·  view source on GitHub ↗

Calculate duration if available (lazy).

(self)

Source from the content-addressed store, hash-verified

191
192 @property
193 def duration(self):
194 """Calculate duration if available (lazy)."""
195 if not self._duration_calculated:
196 self._duration_calculated = True
197
198 # split_tokens = self.split_tokens
199 line_str = self.line_str
200
201 if (line_str
202 and line_str.endswith('ms')
203 and 'Scheduled new oplog query' not in line_str):
204
205 try:
206 # find duration from end
207 space_pos = line_str.rfind(" ")
208 if space_pos == -1:
209 return
210 self._duration = int(line_str[line_str.rfind(" ") +
211 1:-2].replace(',', ''))
212 except ValueError:
213 self._duration = None
214 elif "flushing" in self.line_str:
215 matchobj = re.search(r'flushing mmaps took (\d+)ms',
216 self.line_str)
217 if matchobj:
218 self._duration = int(matchobj.group(1))
219 # SERVER-16176 - Logging of slow checkpoints
220 elif "Checkpoint took" in self.line_str:
221 matchobj = re.search("Checkpoint took ([\d]+) seconds to complete", self.line_str)
222 if matchobj:
223 self._duration = int(matchobj.group(1)) * 1000
224
225 return self._duration
226
227 # SERVER-41349 - get hostname from the DNS log line
228 @property

Callers

nothing calls this directly

Calls 1

groupMethod · 0.45

Tested by

no test coverage detected