Date: Thu, 15 Jul 2010 04:06:44 +0400 From: Anonymous <swell.k@gmail.com> To: Atom Smasher <atom@smasher.org> Cc: freebsd-hackers@freebsd.org Subject: Re: sysctl way too slow Message-ID: <8639vl4nhn.fsf@gmail.com> In-Reply-To: <1007142345320.5546@smasher> (Atom Smasher's message of "Wed, 14 Jul 2010 23:49:07 %2B1200 (NZST)") References: <1007142345320.5546@smasher>
next in thread | previous in thread | raw e-mail | index | archive | help
Atom Smasher <atom@smasher.org> writes: > http://smasher.org/tmp/zsh-bsd-sysctl-slow.png > > is there a way to get this information that doesn't take so long? If you only need sysctl values for fancy prompt then cache them inside variables, e.g. PROMPT='($hw_acpi_battery_life, $hw_acpi_battery_time, $hw_acpi_battery_state) %# ' PERIOD=30 setopt promptsubst periodic_functions+=(sysctl-to-var) sysctl-to-var() { set -- hw.acpi.battery. for i in $(sysctl -N $@); do eval ${i:gs/./_/:gs/%//}='$(sysctl -n $i)' done } To not pollute global scope using one associative array for sysctls may be better. > > the same info is available on linux via /sys and /proc and on > comparable hardware, i can get the info about 100x faster. > > thanks...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8639vl4nhn.fsf>