From: Michael Tremer Date: Fri, 23 Sep 2016 19:21:31 +0000 (+0200) Subject: Cache system_get_processors() X-Git-Tag: 009~275 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=378835b986e163cc873c6cb07a3bdfef2109be23;p=network.git Cache system_get_processors() This function is called quite option and hence we cache the result to speed up code execution Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.system b/src/functions/functions.system index bc5f05b1..947fc304 100644 --- a/src/functions/functions.system +++ b/src/functions/functions.system @@ -19,13 +19,18 @@ # # ############################################################################### -_getconf() { - getconf $@ -} +SYSTEM_PROCESSORS= # Returns the number of online processors system_get_processors() { - _getconf _NPROCESSORS_ONLN + # Cache this since the function is called quite often + isset SYSTEM_PROCESSORS || SYSTEM_PROCESSORS=$(__system_get_processors) + + echo ${SYSTEM_PROCESSORS} +} + +__system_get_processors() { + getconf _NPROCESSORS_ONLN } system_get_next_processor() {