Skip to content

Commit 15a37aa

Browse files
authored
Merge pull request #17 from chregu/cache-concurrency-info
Add cache and concurrency info to phpinfo and methods
2 parents b08067f + 44b7deb commit 15a37aa

File tree

2 files changed

+119
-1
lines changed

2 files changed

+119
-1
lines changed

tests/040.phpt

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
--TEST--
2+
can get info about cache and concurrency
3+
--SKIPIF--
4+
<?php if (!extension_loaded("vips")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$return = vips_cache_get_max_mem();
8+
9+
if (is_int($return)) {
10+
echo "pass vips_cache_get_max_mem\n";
11+
}
12+
13+
$return = vips_cache_get_max_files();
14+
15+
if (is_int($return)) {
16+
echo "pass vips_cache_get_max_files\n";
17+
}
18+
19+
$return = vips_cache_get_max();
20+
21+
if (is_int($return)) {
22+
echo "pass vips_cache_get_max\n";
23+
}
24+
25+
$return = vips_cache_get_size();
26+
27+
if (is_int($return)) {
28+
echo "pass vips_cache_get_size\n";
29+
}
30+
31+
$return = vips_concurrency_get();
32+
33+
if (is_int($return)) {
34+
echo "pass vips_concurrency_get\n";
35+
}
36+
37+
?>
38+
--EXPECT--
39+
pass vips_cache_get_max_mem
40+
pass vips_cache_get_max_files
41+
pass vips_cache_get_max
42+
pass vips_cache_get_size
43+
pass vips_concurrency_get

vips.c

+76-1
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,46 @@ PHP_FUNCTION(vips_version)
17811781
}
17821782
/* }}} */
17831783

1784+
/* {{{ proto integer vips_cache_get_max_mem()
1785+
Get max memory to use for operation cache */
1786+
PHP_FUNCTION(vips_cache_get_max_mem)
1787+
{
1788+
RETURN_LONG(vips_cache_get_max_mem());
1789+
}
1790+
/* }}} */
1791+
1792+
/* {{{ proto integer vips_cache_get_max_files()
1793+
Get max number of open files for operation cache */
1794+
PHP_FUNCTION(vips_cache_get_max_files)
1795+
{
1796+
RETURN_LONG(vips_cache_get_max_files());
1797+
}
1798+
/* }}} */
1799+
1800+
/* {{{ proto integer vips_cache_get_max()
1801+
Get max number of operations to cache */
1802+
PHP_FUNCTION(vips_cache_get_max)
1803+
{
1804+
RETURN_LONG(vips_cache_get_max());
1805+
}
1806+
/* }}} */
1807+
1808+
/* {{{ proto integer vips_cache_get_size()
1809+
Get current cached operations */
1810+
PHP_FUNCTION(vips_cache_get_size)
1811+
{
1812+
RETURN_LONG(vips_cache_get_size());
1813+
}
1814+
/* }}} */
1815+
1816+
/* {{{ proto integer vips_concurrency_get()
1817+
Get number of workers per threadpool */
1818+
PHP_FUNCTION(vips_concurrency_get)
1819+
{
1820+
RETURN_LONG(vips_concurrency_get());
1821+
}
1822+
/* }}} */
1823+
17841824
/* {{{ php_vips_init_globals
17851825
*/
17861826
/* Uncomment this function if you have INI entries
@@ -1930,7 +1970,22 @@ PHP_MINFO_FUNCTION(vips)
19301970
vips_snprintf(digits, 256, "%d", vips_version(2));
19311971
php_info_print_table_row(2, "Micro version", digits);
19321972

1933-
php_info_print_table_row(2, "SIMD support with liborc",
1973+
vips_snprintf(digits, 256, "%zd", vips_cache_get_max_mem());
1974+
php_info_print_table_row(2, "Cache max mem", digits);
1975+
1976+
vips_snprintf(digits, 256, "%d", vips_cache_get_max());
1977+
php_info_print_table_row(2, "Cache max operations", digits);
1978+
1979+
vips_snprintf(digits, 256, "%d", vips_cache_get_size());
1980+
php_info_print_table_row(2, "Cache current operations", digits);
1981+
1982+
vips_snprintf(digits, 256, "%d", vips_cache_get_max_files());
1983+
php_info_print_table_row(2, "Cache max open files", digits);
1984+
1985+
vips_snprintf(digits, 256, "%d", vips_concurrency_get());
1986+
php_info_print_table_row(2, "Concurrency", digits);
1987+
1988+
php_info_print_table_row(2, "SIMD support with liborc",
19341989
vips_vector_isenabled() ? "yes" : "no" );
19351990

19361991
php_info_print_table_row(2, "JPEG support",
@@ -2074,6 +2129,21 @@ ZEND_BEGIN_ARG_INFO(arginfo_vips_concurrency_set, 0)
20742129
ZEND_ARG_INFO(0, value)
20752130
ZEND_END_ARG_INFO()
20762131

2132+
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_max, 0)
2133+
ZEND_END_ARG_INFO()
2134+
2135+
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_max_mem, 0)
2136+
ZEND_END_ARG_INFO()
2137+
2138+
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_max_files, 0)
2139+
ZEND_END_ARG_INFO()
2140+
2141+
ZEND_BEGIN_ARG_INFO(arginfo_vips_cache_get_size, 0)
2142+
ZEND_END_ARG_INFO()
2143+
2144+
ZEND_BEGIN_ARG_INFO(arginfo_vips_concurrency_get, 0)
2145+
ZEND_END_ARG_INFO()
2146+
20772147
ZEND_BEGIN_ARG_INFO(arginfo_vips_version, 0)
20782148
ZEND_END_ARG_INFO()
20792149
/* {{{ vips_functions[]
@@ -2103,6 +2173,11 @@ const zend_function_entry vips_functions[] = {
21032173
PHP_FE(vips_cache_set_max_mem, arginfo_vips_cache_set_max_mem)
21042174
PHP_FE(vips_cache_set_max_files, arginfo_vips_cache_set_max_files)
21052175
PHP_FE(vips_concurrency_set, arginfo_vips_concurrency_set)
2176+
PHP_FE(vips_cache_get_max, arginfo_vips_cache_get_max)
2177+
PHP_FE(vips_cache_get_max_mem, arginfo_vips_cache_get_max_mem)
2178+
PHP_FE(vips_cache_get_max_files, arginfo_vips_cache_get_max_files)
2179+
PHP_FE(vips_cache_get_size, arginfo_vips_cache_get_size)
2180+
PHP_FE(vips_concurrency_get, arginfo_vips_concurrency_get)
21062181
PHP_FE(vips_version, arginfo_vips_version)
21072182

21082183
PHP_FE_END /* Must be the last line in vips_functions[] */

0 commit comments

Comments
 (0)