FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sentry-php/src/Profiling/Profiler.php at source-frame-cache · getsentry/sentry-php · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
getsentry
/
sentry-php
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
475
Star
1.9k
Code
Issues
20
Pull requests
11
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
sentry-php
/
src
/
Profiling
/
Profiler.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
89 lines (70 loc) · 1.84 KB
Breadcrumbs
sentry-php
/
src
/
Profiling
/
Profiler.php
Copy path
File metadata and controls
89 lines (70 loc) · 1.84 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
declare
(strict_types=
1
);
namespace
Sentry
\
Profiling
;
use
Psr
\
Log
\
LoggerInterface
;
use
Psr
\
Log
\
NullLogger
;
use
Sentry
\
Options
;
/**
* @internal
*/
final
class
Profiler
{
/**
* @var \ExcimerProfiler|null
*/
private
$
profiler
;
/**
* @var Profile
*/
private
$
profile
;
/**
* @var LoggerInterface
*/
private
$
logger
;
/**
* @var float The sample rate (10.01ms/101 Hz)
*/
private
const
SAMPLE_RATE
=
0.0101
;
/**
* @var int The maximum stack depth
*/
private
const
MAX_STACK_DEPTH
=
128
;
public
function
__construct
(?
Options
$
options
=
null
)
{
$
this
->
logger
=
$
options
!==
null
?
$
options
->
getLoggerOrNullLogger
() :
new
NullLogger
();
$
this
->
profile
=
new
Profile
(
$
options
);
$
this
->
initProfiler
();
}
public
function
start
():
void
{
if
(
$
this
->
profiler
!==
null
) {
$
this
->
profiler
->
start
();
}
}
public
function
stop
():
void
{
if
(
$
this
->
profiler
!==
null
) {
$
this
->
profiler
->
stop
();
$
this
->
profile
->
setExcimerLog
(
$
this
->
profiler
->
flush
());
}
}
public
function
getProfile
(): ?
Profile
{
if
(
$
this
->
profiler
===
null
) {
return
null
;
}
return
$
this
->
profile
;
}
private
function
initProfiler
():
void
{
if
(!
\extension_loaded
(
'
excimer
'
)) {
$
this
->
logger
->
warning
(
'
The profiler was started but is not available because the "excimer" extension is not loaded.
'
);
return
;
}
$
this
->
profiler
=
new
\
ExcimerProfiler
();
$
this
->
profile
->
setStartTimeStamp
(
microtime
(
true
));
$
this
->
profiler
->
setEventType
(\
EXCIMER_REAL
);
$
this
->
profiler
->
setPeriod
(
self
::
SAMPLE_RATE
);
$
this
->
profiler
->
setMaxDepth
(
self
::
MAX_STACK_DEPTH
);
}
}
Back
|
FazBrowse Home
|
New Git URL