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