Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Peng Yu Newsgroups: gnu.bash.bug Subject: Re: Should [[ -v 1 ]] be supported? Date: Thu, 27 Dec 2018 19:47:08 -0600 Lines: 39 Approved: bug-bash@gnu.org Message-ID: References: <5dac2cf2-2fac-0fd1-058f-6a84a3271738@case.edu> <20181228013623.mersdxbzy64dpldp@crack.deadbeast.net> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1545962583 13657 208.118.235.17 (28 Dec 2018 02:03:03 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash To: "G. Branden Robinson" Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1hKU7nU1S+0zS7iwhsrgiBX6HC9e+DEeSPmgpXy6+Ks=; b=JfXxzZmuHrwHeLyOYn0G74FR/MIvJ+1vxvya+Ft7/h0cszM18d3+/X7tdB0cxVWFyq 6gK+Qw2CGsdUbvIG19SPo+b3phFSqzJsE6PrrL4v3UfAVDoARjEWCx1vCo816eb/Rji4 Mjt02zTpOSdiAqC0cgaZX+OxnRk4PKIfcj/dGNx04Is4wdeRD1hbJkGmf+83RV1brNOb AOyhWfHK9SRrcPQ18rWpDSHKNy3qhhYylT5cKOQF+DpQrrJPAe8CgI7lLCn8meBiVFGm CgGkr9XrcEUzWTUx4pT9zL2rhxSPtLjgBvsdddtg8EVkH+Jn1WuWlKiizGH3Rd8f929y +Hcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1hKU7nU1S+0zS7iwhsrgiBX6HC9e+DEeSPmgpXy6+Ks=; b=jYTbZjVsl/HeXJU2dpHA+AnJB8hAK90h2FIW3q5atYvTE+T1Le8L01Rhxxgqls6ie9 mX46l4aqPJ+6qwQJPC+y+DHdy6kImta+Iq3lx2Uw9QxDX0pdzOFvjTmgcsWXXXUJlER2 I7uOYOVChIAHNU3AVbgfsXYufXaa3eKfzDJ7C8Us1l4Tzz6bXliW3gn/ZdqKMcgT4YYP h33kr3NsEJfdoeJzBKYX3U1MJMIbYibZBjmeCEMVPOEWLr/qO4m9Gvi/iJtfOZvWr2jd j3qzCier4oM/IGgEZKkee57Ka2Yy/4hqdWBcb+a+nPFE7LEMtQk68khYp7PQ5FQFtxJs td4Q== X-Gm-Message-State: AA+aEWYTrje5AvPyvkrdXMP/pngQvLMh759+Tl7pQQjmMD0UjIXDjSDI 0wf0W6i9lHbTmUCg5ZsythOvmI9t1CC/GWjvOF0= X-Google-Smtp-Source: AFSGD/WBzr2CpUogWoLsXiK+5xA6IEYfjoHR3URhtJF8XA9B3eUyp8kghpZfsASQIeSsbgzjG1NaxCUGbuqaTA7sq90= X-Received: by 2002:a02:6915:: with SMTP id e21mr17475741jac.142.1545961639932; Thu, 27 Dec 2018 17:47:19 -0800 (PST) In-Reply-To: <20181228013623.mersdxbzy64dpldp@crack.deadbeast.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::131 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14984 On Thu, Dec 27, 2018 at 7:37 PM G. Branden Robinson wrote: > > At 2018-12-27T18:39:26-0600, Peng Yu wrote: > > What I meant in my original email is that I want something for testing > > if there is a command line argument (one or more, the exact number > > does not matter). $# gives more than that info, because it tells not > > only whether is any command line argument, but also how many. This > > could lead to slower performance if the goal is to just test if there > > is an argument. > > You should look into how integer comparisons are done in hardware. > > For instance, comparison and subtraction operations are often comparable > (or even identical) in cycle count because they both perform a > subtraction "under the hood". You need to be programming in assembly > language to influence execution at such depths. > > See, e.g., > > https://www.quora.com/What-is-the-difference-between-cmp-and-sub-instruction-in-8086microprocessor > > As others have noted, if you are worried about marginal performance > impacts this small, margin you are probably writing in the wrong > language, or distracting yourself with tiny details when you do not even > know the cyclomatic complexity of your code or the big-O classification > of your algorithms. > > Attack those problems first, and see what you discover. The problem is that bash is not systematically profiled for performance at all. I am doing it step it by step. There are many more that I have already tested. You can not dismiss this one just because it may not have a large impact. -- Regards, Peng