From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19596 invoked by alias); 19 Jan 2013 19:23:19 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17594 Received: (qmail 21258 invoked from network); 19 Jan 2013 19:23:17 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.eastlink.ca designates 24.224.136.30 as permitted sender) X-Authority-Analysis: v=2.0 cv=ALuRCTdV c=1 sm=1 a=b3SXY1D4cuMtXB6W/vj6fA==:17 a=0wiOde9d68gA:10 a=s3ldoGM7zx0A:10 a=8nJEP1OIZ-IA:10 a=dYHNzzUVHNgA:10 a=X6Lz7nJ-ZMWPfuHoV5oA:9 a=wPNLvfGTeEIA:10 a=b3SXY1D4cuMtXB6W/vj6fA==:117 Message-id: <50FAEB96.3000205@eastlink.ca> Date: Sat, 19 Jan 2013 10:53:10 -0800 From: Ray Andrews User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-version: 1.0 To: zsh-users@zsh.org Subject: Re: zsh functions not playing nice. References: <50FAD0AF.60506@eastlink.ca> <20130119173807.GB7039@chaz.gmail.com> In-reply-to: <20130119173807.GB7039@chaz.gmail.com> Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit On 19/01/13 09:38 AM, Stephane Chazelas wrote: Thanks. This is a bit over my head but I get some idea. > > ~$ type nice > nice is /usr/bin/nice > > There's no way it can know about a zsh function which is > something internal to the shell. > > It *executes* a command. So what you think is a builtin is > the command version of it in /bin or /usr/bin: Yes, so I see. > ~$ strace -fe execve nice echo test > execve("/bin/echo", ["echo", "test"], [/* 40 vars */]) = 0 > > What you could do is: > > some-zsh-function & renice $!; fg > > Note that it would run that function in a subshell. > What I'm experimenting with is some way to get consistent run times for various functions that I'm writing, so as to optimize them. It's quite educational. But the runtimes vary hugely so it's hard to say if any given change has had a positive effect. I was thinking that if I set the niceness to maximum, then maybe the times would smooth out since other processes would be less likely to interfere. Looking at the above, what I'm now doing is just: renice -n -20 -u root ... and then just running the function normally. It sure makes things go faster, and it does smooth the runtimes out a bit, tho not perfectly.