Calculate duration if available (lazy).

def duration(self):
        """Calculate duration if available (lazy)."""
        if not self._duration_calculated:
            self._duration_calculated = True

            # split_tokens = self.split_tokens
            line_str = self.line_str

            if (line_str
                and line_str.endswith('ms')
                and 'Scheduled new oplog query' not in line_str):

                try:
                    # find duration from end
                    space_pos = line_str.rfind(" ")
                    if space_pos == -1:
                        return
                    self._duration = int(line_str[line_str.rfind(" ") +
                                                  1:-2].replace(',', ''))
                except ValueError:
                    self._duration = None
            elif "flushing" in self.line_str:
                matchobj = re.search(r'flushing mmaps took (\d+)ms',
                                     self.line_str)
                if matchobj:
                    self._duration = int(matchobj.group(1))

        return self._duration