You are here

class StopwatchPeriod in Devel 4.x

Same name and namespace in other branches
  1. 8.3 webprofiler/src/Stopwatch.php \Drupal\webprofiler\StopwatchPeriod
  2. 8 webprofiler/src/Stopwatch.php \Drupal\webprofiler\StopwatchPeriod
  3. 8.2 webprofiler/src/Stopwatch.php \Drupal\webprofiler\StopwatchPeriod

Class StopwatchPeriod.

Hierarchy

Expanded class hierarchy of StopwatchPeriod

File

webprofiler/src/Stopwatch.php, line 548

Namespace

Drupal\webprofiler
View source
class StopwatchPeriod {
  private $start;
  private $end;
  private $memory;

  /**
   * Constructor.
   *
   * @param int $start
   *   The relative time of the start of the period (in milliseconds)
   * @param int $end
   *   The relative time of the end of the period (in milliseconds)
   */
  public function __construct($start, $end) {
    $this->start = (int) $start;
    $this->end = (int) $end;
    $this->memory = memory_get_usage(TRUE);
  }

  /**
   * Gets the relative time of the start of the period.
   *
   * @return int
   *   The time (in milliseconds).
   */
  public function getStartTime() {
    return $this->start;
  }

  /**
   * Gets the relative time of the end of the period.
   *
   * @return int
   *   The time (in milliseconds).
   */
  public function getEndTime() {
    return $this->end;
  }

  /**
   * Gets the time spent in this period.
   *
   * @return int
   *   The period duration (in milliseconds).
   */
  public function getDuration() {
    return $this->end - $this->start;
  }

  /**
   * Gets the memory usage.
   *
   * @return int
   *   The memory usage (in bytes).
   */
  public function getMemory() {
    return $this->memory;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StopwatchPeriod::$end private property
StopwatchPeriod::$memory private property
StopwatchPeriod::$start private property
StopwatchPeriod::getDuration public function Gets the time spent in this period.
StopwatchPeriod::getEndTime public function Gets the relative time of the end of the period.
StopwatchPeriod::getMemory public function Gets the memory usage.
StopwatchPeriod::getStartTime public function Gets the relative time of the start of the period.
StopwatchPeriod::__construct public function Constructor.