This repository has been archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
newrelic_profiler.cpp
52 lines (43 loc) · 2.16 KB
/
newrelic_profiler.cpp
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
/*
+----------------------------------------------------------------------+
| HipHop for PHP |
+----------------------------------------------------------------------+
| Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
| Copyright (c) 1997-2010 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
*/
#include "newrelic_profiler.h"
#include "hphp/runtime/ext/hotprofiler/ext_hotprofiler.h"
namespace HPHP {
void NewRelicProfiler::beginFrameEx(const char *symbol) {
NewRelicProfilerFrame *frame = dynamic_cast<NewRelicProfilerFrame *>(m_stack);
if (m_stack->m_parent) {
NewRelicProfilerFrame *p = dynamic_cast<NewRelicProfilerFrame *>(frame->m_parent);
frame->m_nr_depth = p->m_nr_depth + 1;
} else {
frame->m_nr_depth = 0;
}
frame->m_nr_segement_code = 0;
if (frame->m_nr_depth < max_depth) {
frame->m_nr_segement_code = newrelic_segment_generic_begin(NEWRELIC_AUTOSCOPE, NEWRELIC_AUTOSCOPE, frame->m_name);
}
}
void NewRelicProfiler::endFrameEx(const TypedValue *retval,
const char *given_symbol) {
char symbol[512];
NewRelicProfilerFrame *frame = dynamic_cast<NewRelicProfilerFrame *>(m_stack);
frame->getStack(2, symbol, sizeof(symbol));
if (frame->m_nr_segement_code > 0) {
newrelic_segment_end(NEWRELIC_AUTOSCOPE, frame->m_nr_segement_code);
frame->m_nr_segement_code = 0;
}
}
}