From owner-freebsd-hackers@FreeBSD.ORG Thu Jul 15 00:31:50 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3E25C106564A for ; Thu, 15 Jul 2010 00:31:50 +0000 (UTC) (envelope-from swell.k@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id BC51E8FC15 for ; Thu, 15 Jul 2010 00:31:49 +0000 (UTC) Received: by bwz12 with SMTP id 12so138009bwz.13 for ; Wed, 14 Jul 2010 17:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:references :date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=kTCUCC07z0bLu4V/pTR+8WT8nfgxVhvb2qNlQtyhvc8=; b=pCQs4Evm2trbzrpYGcdKIRfxIGZK1Ct9ADc89lKoKukFftzMw0K0Rko6cO50EQ9Gpm 3BbVstffeSaJgqg2K93gmrZwwaSyIv+BTtsVomcPC0Q6xM5QkxzXNhVjgib1YZJrHYXG mDjUhD+WuW5lxjioY9rtHIYauATpyuJjwAUEM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=mcJUpGrnwL8CPUVjASZvpifBmqm7T1mvrXr2vhluG/11QUylX5qMPnWgD66O0f8GVj gdrGHHBOi9DxIJPGHQlFWQ5zWXBa3uBnDFAX5FTpbcefvpTZE9R0QAAoR1YLSFOuTjLu 15c9IfN/HdC6ViEm3s5NhxjBpBv+mD8e4jHRM= Received: by 10.204.0.83 with SMTP id 19mr14015897bka.67.1279152424758; Wed, 14 Jul 2010 17:07:04 -0700 (PDT) Received: from localhost ([88.198.6.155]) by mx.google.com with ESMTPS id y2sm3098455bkx.8.2010.07.14.17.06.56 (version=SSLv3 cipher=RC4-MD5); Wed, 14 Jul 2010 17:07:03 -0700 (PDT) From: Anonymous To: Atom Smasher References: <1007142345320.5546@smasher> Date: Thu, 15 Jul 2010 04:06:44 +0400 In-Reply-To: <1007142345320.5546@smasher> (Atom Smasher's message of "Wed, 14 Jul 2010 23:49:07 +1200 (NZST)") Message-ID: <8639vl4nhn.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailman-Approved-At: Thu, 15 Jul 2010 03:55:08 +0000 Cc: freebsd-hackers@freebsd.org Subject: Re: sysctl way too slow X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jul 2010 00:31:50 -0000 Atom Smasher 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...