def get_time_range(args): default_unit = 's' start = prof.parse_time_as_nanos(args.since, default_unit=default_unit) if args.since else None end = prof.parse_time_as_nanos(args.until, default_unit=default_unit) if args.until else None if args.period: if start and end: raise InvalidArgumentsException("--period cannot be used when both --since and --until are specified") period = prof.parse_time_as_nanos(args.period) if start: end = start + period elif end: start = end - period else: raise InvalidArgumentsException("--period must be used with --since or --until specified") return trace.TimeRange(start, end)
def time_range(self): return trace.TimeRange(self.timestamp, self.timestamp + self.resident_time)