Skip to content

Commit 281dea6

Browse files
authored
Remove memprof_enable() function (#107)
Enabling profiling during request may not work as expected because of PHP optimizations and observer behavior. Supporting that would increase overhead when not profiling. Using MEMPROF_PROFILE is now the only way to enable profiling.
1 parent d7eb44f commit 281dea6

File tree

8 files changed

+317
-83
lines changed

8 files changed

+317
-83
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jobs:
1212
tests:
1313
name: 'Tests'
1414
strategy:
15+
fail-fast: false
1516
matrix:
1617
include:
1718
- php: '8.4.0'

memprof.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,28 +1765,6 @@ PHP_FUNCTION(memprof_memory_get_peak_usage)
17651765
}
17661766
/* }}} */
17671767

1768-
/* {{{ proto bool memprof_enable()
1769-
Enables memprof */
1770-
PHP_FUNCTION(memprof_enable)
1771-
{
1772-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) {
1773-
return;
1774-
}
1775-
1776-
if (MEMPROF_G(profile_flags).enabled) {
1777-
zend_throw_exception(EG(exception_class), "memprof_enable(): memprof is already enabled", 0);
1778-
return;
1779-
}
1780-
1781-
zend_error(E_WARNING, "Calling memprof_enable() manually may not work as expected because of PHP optimizations. Prefer using MEMPROF_PROFILE=1 as environment variable, GET, or POST");
1782-
1783-
MEMPROF_G(profile_flags).enabled = 1;
1784-
memprof_enable(&MEMPROF_G(profile_flags));
1785-
1786-
RETURN_TRUE;
1787-
}
1788-
/* }}} */
1789-
17901768
/* {{{ proto bool memprof_disable()
17911769
Disables memprof */
17921770
PHP_FUNCTION(memprof_disable)

memprof.stub.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ function memprof_enabled(): bool {}
99

1010
function memprof_enabled_flags(): array {}
1111

12-
function memprof_enable(): bool {}
13-
1412
function memprof_disable(): bool {}
1513

1614
function memprof_dump_array(): array {}

memprof_arginfo.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: afb43b76aec85442c7267aba0b45bfd00d5c8cf1 */
2+
* Stub hash: a8dec2138f524b2d8e0e5e07631e4965250fbbba */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memprof_enabled, 0, 0, _IS_BOOL, 0)
55
ZEND_END_ARG_INFO()
66

77
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_memprof_enabled_flags, 0, 0, IS_ARRAY, 0)
88
ZEND_END_ARG_INFO()
99

10-
#define arginfo_memprof_enable arginfo_memprof_enabled
11-
1210
#define arginfo_memprof_disable arginfo_memprof_enabled
1311

1412
#define arginfo_memprof_dump_array arginfo_memprof_enabled_flags
@@ -25,7 +23,6 @@ ZEND_END_ARG_INFO()
2523

2624
ZEND_FUNCTION(memprof_enabled);
2725
ZEND_FUNCTION(memprof_enabled_flags);
28-
ZEND_FUNCTION(memprof_enable);
2926
ZEND_FUNCTION(memprof_disable);
3027
ZEND_FUNCTION(memprof_dump_array);
3128
ZEND_FUNCTION(memprof_dump_callgrind);
@@ -36,7 +33,6 @@ ZEND_FUNCTION(memprof_version);
3633
static const zend_function_entry ext_functions[] = {
3734
ZEND_FE(memprof_enabled, arginfo_memprof_enabled)
3835
ZEND_FE(memprof_enabled_flags, arginfo_memprof_enabled_flags)
39-
ZEND_FE(memprof_enable, arginfo_memprof_enable)
4036
ZEND_FE(memprof_disable, arginfo_memprof_disable)
4137
ZEND_FE(memprof_dump_array, arginfo_memprof_dump_array)
4238
ZEND_FE(memprof_dump_callgrind, arginfo_memprof_dump_callgrind)

package.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
<file name="INTERNALS.md" role="doc" />
4242
<file name="README.md" role="doc" />
4343
<dir name="tests">
44-
<file name="001.phpt" role="test" />
4544
<file name="002.phpt" role="test" />
4645
<file name="003.phpt" role="test" />
4746
<file name="004.phpt" role="test" />

tests/001.phpt

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)