1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
stopwatch.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\Diag;
4
6{
7 // seconds with nanoseconds
8 protected ?float $start = null;
9 protected float $timer = 0.0;
10 protected int $precision;
11
12 public function __construct(int $precision = 6)
13 {
14 $this->precision = $precision;
15 }
16
17 public function start(): static
18 {
19 $this->start = hrtime(true);
20
21 return $this;
22 }
23
24 public function stop(): float
25 {
26 if ($this->start !== null)
27 {
28 $this->timer += (hrtime(true) - $this->start)/1e+9;
29 $this->start = null;
30 }
31
32 return $this->get();
33 }
34
35 public function reset(): static
36 {
37 return $this->set(0.0);
38 }
39
40 public function flyback(): float
41 {
42 $time = $this->stop();
43 $this->reset();
44 $this->start();
45
46 return $time;
47 }
48
49 public function set(float $timer): static
50 {
51 $this->timer = $timer;
52 $this->start = null;
53
54 return $this;
55 }
56
57 public function get(): float
58 {
59 return round($this->timer, $this->precision);
60 }
61}
float $start
Определения stopwatch.php:8
float $timer
Определения stopwatch.php:9
int $precision
Определения stopwatch.php:10
__construct(int $precision=6)
Определения stopwatch.php:12
$time
Определения payment.php:61