text: # Unless explicitly stated otherwise all files in this repository are licensed
  # under the Apache License Version 2.0.
  # This product includes software developed at Datadog (https://www.datadoghq.com/).
  # Copyright 2017 Datadog, Inc.
  
  # (C) Datadog, Inc. 2010-2017
  # All rights reserved
  # Licensed under Simplified BSD License (see LICENSE)
  
  # stdlib
  import time
  
  class Timer(object):
      """ Helper class """
  
      def __init__(self):
          self.start()
  
      def _now(self):
          return time.time()
  
      def start(self):
          self.started = self._now()
          self.last = self.started
          return self
  
      def step(self):
          now = self._now()
          step = now - self.last
          self.last = now
          return step
  
      def total(self, as_sec=True):
          return self._now() - self.started
  