Skip to content

Commit 811f20a

Browse files
committed
Added information about preloading to opcache_get_status()
1 parent 093e8b1 commit 811f20a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

ext/opcache/zend_accelerator_module.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,44 @@ static ZEND_FUNCTION(opcache_get_status)
662662
add_assoc_double(&statistics, "opcache_hit_rate", reqs?(((double) ZCSG(hits))/reqs)*100.0:0);
663663
add_assoc_zval(return_value, "opcache_statistics", &statistics);
664664

665+
if (ZCSG(preload_script)) {
666+
array_init(&statistics);
667+
668+
add_assoc_long(&statistics, "memory_consumption", ZCSG(preload_script)->dynamic_members.memory_consumption);
669+
670+
if (zend_hash_num_elements(&ZCSG(preload_script)->script.function_table)) {
671+
zend_op_array *op_array;
672+
673+
array_init(&scripts);
674+
ZEND_HASH_FOREACH_PTR(&ZCSG(preload_script)->script.function_table, op_array) {
675+
add_next_index_str(&scripts, op_array->function_name);
676+
} ZEND_HASH_FOREACH_END();
677+
add_assoc_zval(&statistics, "functions", &scripts);
678+
}
679+
680+
if (zend_hash_num_elements(&ZCSG(preload_script)->script.class_table)) {
681+
zend_class_entry *ce;
682+
683+
array_init(&scripts);
684+
ZEND_HASH_FOREACH_PTR(&ZCSG(preload_script)->script.class_table, ce) {
685+
add_next_index_str(&scripts, ce->name);
686+
} ZEND_HASH_FOREACH_END();
687+
add_assoc_zval(&statistics, "classes", &scripts);
688+
}
689+
690+
if (ZCSG(saved_scripts)) {
691+
zend_persistent_script **p = ZCSG(saved_scripts);
692+
693+
array_init(&scripts);
694+
while (*p) {
695+
add_next_index_str(&scripts, (*p)->script.filename);
696+
p++;
697+
}
698+
add_assoc_zval(&statistics, "scripts", &scripts);
699+
}
700+
add_assoc_zval(return_value, "preload_statistics", &statistics);
701+
}
702+
665703
if (fetch_scripts) {
666704
/* accelerated scripts */
667705
if (accelerator_get_scripts(&scripts)) {

0 commit comments

Comments
 (0)