Measurement.php
137 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Matomo - free/libre analytics platform |
| 5 | * |
| 6 | * @link https://matomo.org |
| 7 | * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 8 | */ |
| 9 | namespace Piwik\CronArchive\Performance; |
| 10 | |
| 11 | class Measurement |
| 12 | { |
| 13 | /** |
| 14 | * @var string |
| 15 | */ |
| 16 | private $category; |
| 17 | /** |
| 18 | * @var string |
| 19 | */ |
| 20 | private $measuredName; |
| 21 | /** |
| 22 | * @var string |
| 23 | */ |
| 24 | private $idSite; |
| 25 | /** |
| 26 | * @var string |
| 27 | */ |
| 28 | private $dateRange; |
| 29 | /** |
| 30 | * @var string |
| 31 | */ |
| 32 | private $periodType; |
| 33 | /** |
| 34 | * @var string |
| 35 | */ |
| 36 | private $segment; |
| 37 | /** |
| 38 | * @var float |
| 39 | */ |
| 40 | private $time; |
| 41 | /** |
| 42 | * @var string |
| 43 | */ |
| 44 | private $memory; |
| 45 | /** |
| 46 | * @var string |
| 47 | */ |
| 48 | private $peakMemory; |
| 49 | public function __construct($category, $name, $idSite, $dateRange, $periodType, $segment, $time, $memory, $peakMemory) |
| 50 | { |
| 51 | $this->category = $category; |
| 52 | $this->measuredName = $name; |
| 53 | $this->idSite = $idSite; |
| 54 | $this->dateRange = $dateRange; |
| 55 | $this->periodType = $periodType; |
| 56 | $this->segment = trim($segment); |
| 57 | $this->time = $time; |
| 58 | $this->memory = $memory; |
| 59 | $this->peakMemory = $peakMemory; |
| 60 | } |
| 61 | public function __toString() |
| 62 | { |
| 63 | $parts = [ucfirst($this->category) . ": {$this->measuredName}", "idSite: {$this->idSite}", "period: {$this->periodType} ({$this->dateRange})", "segment: " . (!empty($this->segment) ? $this->segment : 'none'), "duration: {$this->time}s", "memory leak: {$this->memory}", "peak memory usage: {$this->peakMemory}"]; |
| 64 | return implode(', ', $parts); |
| 65 | } |
| 66 | /** |
| 67 | * @return string |
| 68 | */ |
| 69 | public function getCategory() |
| 70 | { |
| 71 | return $this->category; |
| 72 | } |
| 73 | /** |
| 74 | * @param string $category |
| 75 | */ |
| 76 | public function setCategory($category) |
| 77 | { |
| 78 | $this->category = $category; |
| 79 | } |
| 80 | /** |
| 81 | * @return string |
| 82 | */ |
| 83 | public function getMeasuredName() |
| 84 | { |
| 85 | return $this->measuredName; |
| 86 | } |
| 87 | /** |
| 88 | * @param string $measuredName |
| 89 | */ |
| 90 | public function setMeasuredName($measuredName) |
| 91 | { |
| 92 | $this->measuredName = $measuredName; |
| 93 | } |
| 94 | /** |
| 95 | * @return string |
| 96 | */ |
| 97 | public function getIdSite() |
| 98 | { |
| 99 | return $this->idSite; |
| 100 | } |
| 101 | /** |
| 102 | * @param string $idSite |
| 103 | */ |
| 104 | public function setIdSite($idSite) |
| 105 | { |
| 106 | $this->idSite = $idSite; |
| 107 | } |
| 108 | /** |
| 109 | * @return string |
| 110 | */ |
| 111 | public function getDateRange() |
| 112 | { |
| 113 | return $this->dateRange; |
| 114 | } |
| 115 | /** |
| 116 | * @param string $dateRange |
| 117 | */ |
| 118 | public function setDateRange($dateRange) |
| 119 | { |
| 120 | $this->dateRange = $dateRange; |
| 121 | } |
| 122 | /** |
| 123 | * @return string |
| 124 | */ |
| 125 | public function getPeriodType() |
| 126 | { |
| 127 | return $this->periodType; |
| 128 | } |
| 129 | /** |
| 130 | * @param string $periodType |
| 131 | */ |
| 132 | public function setPeriodType($periodType) |
| 133 | { |
| 134 | $this->periodType = $periodType; |
| 135 | } |
| 136 | } |
| 137 |