dbxapp 4.1.3
CMS, Shop, Workflows und modulare Geschäftsanwendungen
Loading...
Searching...
No Matches
dbxRuntime.class.php
Go to the documentation of this file.
1<?php
2
6class dbxRuntime {
7
11 public function current_php_runtime(): float {
12 global $dbx_run_timer;
13
14 if (isset($dbx_run_timer['system']['time'])
15 && is_numeric($dbx_run_timer['system']['time'])
16 && (float)$dbx_run_timer['system']['time'] >= 0) {
17 return (float)$dbx_run_timer['system']['time'];
18 }
19
20 if (isset($dbx_run_timer['system']['start_time'])
21 && is_numeric($dbx_run_timer['system']['start_time'])) {
22 return max(0.0, microtime(true) - (float)$dbx_run_timer['system']['start_time']);
23 }
24
25 return 0.0;
26 }
27
31 public function current_memory_bytes(): int {
32 global $dbx_run_timer;
33
34 if (isset($dbx_run_timer['system']['memory'])
35 && is_numeric($dbx_run_timer['system']['memory'])
36 && (float)$dbx_run_timer['system']['memory'] >= 0) {
37 return (int)round((float)$dbx_run_timer['system']['memory']);
38 }
39
40 if (isset($dbx_run_timer['system']['start_memory'], $dbx_run_timer['system']['end_memory'])
41 && is_numeric($dbx_run_timer['system']['start_memory'])
42 && is_numeric($dbx_run_timer['system']['end_memory'])) {
43 return max(
44 0,
45 (int)round(
46 (float)$dbx_run_timer['system']['end_memory']
47 - (float)$dbx_run_timer['system']['start_memory']
48 )
49 );
50 }
51
52 return 0;
53 }
54
58 public function send_headers(): void {
59 if (headers_sent()) {
60 return;
61 }
62
63 $runtime = $this->current_php_runtime();
64 header('X-Content-Type-Options: nosniff');
65 header('Referrer-Policy: strict-origin-when-cross-origin');
66 header('X-Frame-Options: SAMEORIGIN');
67 header('X-DBX-PHP-Runtime: ' . number_format($runtime, 3, '.', ''));
68 header(
69 'Server-Timing: dbxphp;dur='
70 . number_format($runtime * 1000, 3, '.', '')
71 . ';desc="DBX PHP Runtime"',
72 false
73 );
74 }
75
79 public function debug_timer(float $max = 0): void {
80 global $dbx_run_timer;
81
82 if (!isset($dbx_run_timer['system']['time'])) {
83 return;
84 }
85
86 $time = (float)$dbx_run_timer['system']['time'];
87 if ($time > $max) {
88 dbx()->debug('#RUN-TIMER', $dbx_run_timer);
89 return;
90 }
91
92 dbx()->debug("dbx System run time=($time)");
93 }
94
98 public function store_performance_timer(): int {
99 try {
100 $file = dbx()->os_path(
101 dbx()->get_base_dir() . 'dbx/modules/dbx/include/dbxPerformanceTimer.class.php'
102 );
103 if (!is_file($file)) {
104 return 0;
105 }
106
107 include_once $file;
108 if (!class_exists('dbxPerformanceTimer')) {
109 return 0;
110 }
111
112 $timer = new \dbxPerformanceTimer();
113 return method_exists($timer, 'store') ? (int)$timer->store() : 0;
114 } catch (\Throwable $e) {
115 dbx()->write_php_error_log(
116 get_class($e),
117 $e->getMessage(),
118 $e->getFile(),
119 $e->getLine()
120 );
121 return 0;
122 }
123 }
124}
Laufzeit-, Response-Header- und Performance-Helfer des Systemkerns.
send_headers()
Sendet die Laufzeitdaten als Response-Header.
current_php_runtime()
Liefert die aktuelle PHP-Laufzeit des Requests in Sekunden.
debug_timer(float $max=0)
Gibt die gesammelte Laufzeitmessung für Debugzwecke aus.
store_performance_timer()
Übergibt die Persistenz an das Performance-Modul.
current_memory_bytes()
Liefert den von dbx gemessenen Memory-Verbrauch des Requests in Bytes.
os_path(string $path)
Normalisiert einen Pfad fuer das aktuelle Betriebssystem.
Definition dbxApi.php:1538
get_base_dir(int $cutData=0)
Liefert das Basisverzeichnis der Installation.
Definition dbxApi.php:1507
if(!defined( 'IMG_WEBP')) define( 'IMG_WEBP'
DBX schema administration.