forked from aterrien/forp-PHP-profiler
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathforp.h
More file actions
executable file
·131 lines (103 loc) · 4.43 KB
/
forp.h
File metadata and controls
executable file
·131 lines (103 loc) · 4.43 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
+----------------------------------------------------------------------+
| Forp |
+----------------------------------------------------------------------+
| Copyright (c) 2012 Anthony Terrien |
+----------------------------------------------------------------------+
| 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 |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Anthony Terrien <forp@anthonyterrien.com> |
+----------------------------------------------------------------------+
*/
#ifndef FORP_H
#define FORP_H
#include "php.h"
#include "forp_string.h"
#include "forp_log.h"
#ifdef ZTS
#include "TSRM.h"
#endif
#define FORP_DUMP_ASSOC_FILE "file"
#define FORP_DUMP_ASSOC_CLASS "class"
#define FORP_DUMP_ASSOC_FUNCTION "function"
#define FORP_DUMP_ASSOC_LINENO "lineno"
#define FORP_DUMP_ASSOC_DURATION "usec"
#define FORP_DUMP_ASSOC_PROFILERTIME "pusec"
#define FORP_DUMP_ASSOC_MEMORY "bytes"
#define FORP_DUMP_ASSOC_LEVEL "level"
#define FORP_DUMP_ASSOC_PARENT "parent"
#define FORP_DUMP_ASSOC_GROUPS "groups"
#define FORP_DUMP_ASSOC_CAPTION "caption"
#define FORP_HIGHLIGHT_BEGIN "<div style='position: relative; border: 1px solid #555; margin: 2px; padding: 20px 2px 2px 2px'>"
#define FORP_HIGHLIGHT_END "<div style='position: absolute; top: 0px; right: 0px; left: 0px; height: 14px; background: #555; color: #eee; padding: 2px 5px; font-family: Consolas, monaco, monospace; font-size: 10px; text-align: right'>%s [%.03f ms, %d b, level %d]</div></div>"
#define FORP_STACK_REALLOC 1000
typedef struct forp_function_t {
char *filename;
char *class;
char *function;
int type;
char **groups;
int groups_len;
char *highlight;
} forp_function_t;
typedef struct forp_node_t {
int key;
int state;
char *filename;
int lineno;
int level;
struct forp_node_t *parent;
char *caption;
char *alias;
forp_function_t function;
// Memory
signed long mem;
signed long mem_begin;
signed long mem_end;
// Duration
double time;
double time_begin;
long time_begin_timestamp_microseconds;
double time_end;
// Self cost
double profiler_duration;
} forp_node_t;
/* Zend API proxies */
#if PHP_VERSION_ID < 50500
void (*old_execute)(zend_op_array *op_array TSRMLS_DC);
void forp_execute(zend_op_array *op_array TSRMLS_DC);
void (*old_execute_internal)(zend_execute_data *current_execute_data, int return_value_used TSRMLS_DC);
void forp_execute_internal(zend_execute_data *current_execute_data, int return_value_used TSRMLS_DC);
#else
void (*old_execute_ex)(zend_execute_data *execute_data TSRMLS_DC);
void forp_execute_ex(zend_execute_data *execute_data TSRMLS_DC);
void (*old_execute_internal)(zend_execute_data *current_execute_data, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC);
void forp_execute_internal(zend_execute_data *current_execute_data, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC);
#endif
static void forp_populate_function(forp_function_t *function, zend_execute_data *edata, zend_op_array *op_array TSRMLS_DC);
void forp_info(TSRMLS_D);
void forp_start(TSRMLS_D);
void forp_end(TSRMLS_D);
forp_node_t *forp_open_node(zend_execute_data *edata, zend_op_array *op_array TSRMLS_DC);
void forp_close_node(forp_node_t *pn TSRMLS_DC);
zval *forp_stack_dump_var(forp_var_t *var TSRMLS_DC);
void forp_stack_dump(TSRMLS_D);
void forp_stack_dump_cli_node(forp_node_t *node TSRMLS_DC);
void forp_stack_dump_cli_var(forp_var_t *var, int depth TSRMLS_DC);
void forp_stack_dump_cli(TSRMLS_D);
int forp_is_profiling_function(forp_node_t *n TSRMLS_DC);
#endif /* FORP_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/