Skip to content

Commit 3cd6045

Browse files
committed
Merge branch 'master' of github.com:jcupitt/php-vips-ext
2 parents 687b7f1 + 15a37aa commit 3cd6045

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
@@ -1782,6 +1782,46 @@ PHP_FUNCTION(vips_version)
17821782
}
17831783
/* }}} */
17841784

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

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

19371992
php_info_print_table_row(2, "JPEG support",
@@ -2075,6 +2130,21 @@ ZEND_BEGIN_ARG_INFO(arginfo_vips_concurrency_set, 0)
20752130
ZEND_ARG_INFO(0, value)
20762131
ZEND_END_ARG_INFO()
20772132

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

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

0 commit comments

Comments
 (0)