From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19753 invoked by alias); 9 Mar 2018 13:23:58 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42436 Received: (qmail 19021 invoked by uid 1010); 9 Mar 2018 13:23:57 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr0-f172.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.128.172):SA:0(-1.9/5.0):. Processed in 7.022674 secs); 09 Mar 2018 13:23:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=WAZtSPF3/BFCWp0X5thZfmCeTcjazePNUqQlPKC1tw0=; b=NB7KqQEbP9R4REUim0Gu3AYdL77KAKBa2JdT5su1b5G1N7G9xOmQWeAQcUw57PqlLh 9hxIo4yqxFTNi9f8N4qIaqnD7tzby0YNz0OHBdCbXlcA7GvMJ8qyZpi1bOO9WdIU14Z1 Zb2uHPNOtCrTJstj9OvCZSQuFSsH7FrLO0osS/9e+mv8tk9s5jS52OnkGYDv43vkRUEU QEOm0BxJhaYD+ahPnGQ5jXyepyD+40Z5XQmedOnpQU6sYpIx9I9Fe/Z+uSWZw9Y+zLB8 O0t44N3NMlSyQ8qCeCevU/RDmf6K97bZESbZ7FkfU8ErpXVUWQXHhXULdjSyOvk66tJq NNzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=WAZtSPF3/BFCWp0X5thZfmCeTcjazePNUqQlPKC1tw0=; b=KC2zJxHUF0rCvkngALV+JOC+/SOB1m+WG7LoCiGjk5PNAv2ZahYYt+5KZNDOQOE2Xd pERppwBEjchECZgsX0l12B1tiHrlgqWAuy1uUztJOIqQNbXnDCN32N4Pf/4yVR4SeirD +R/010F+frZ+tljsY1ociepjNBLR12rF68aowvkiI9Edswwi/J3kaOHcCQgyww4Y9d/l 9u+ZZsIrJ++LlCWhMkBUq6wOYQQt8u6uKz5shPQ22RzXTRmrBtrZDfI4bDWq6mmbjs/1 FBh3bqNMNaJhpr0Aa8gB815S/xK0OyJKMP5cIles4vCWfsDBcs6RbaIqN13xyuXJiH6R 7HVQ== X-Gm-Message-State: APf1xPCmWPYlbehGgqdI1MdVTW7HlifjorhjGGn+bj++urtxHL53cbZy ZEMpYF4D1FLlRV2EghPA9ac= X-Google-Smtp-Source: AG47ELsbwI9gnUpsulGf/Dp45pH6374I/FUWryPcLEbM0JB9oYJhs3tvLBS0KOqMW4gGBs9LHVSIuA== X-Received: by 10.223.160.125 with SMTP id l58mr24650360wrl.264.1520601826311; Fri, 09 Mar 2018 05:23:46 -0800 (PST) Date: Fri, 9 Mar 2018 13:23:44 +0000 From: Stephane Chazelas To: Sebastian Gniazdowski Cc: Zsh hackers list Subject: Re: Performance tests of quoting and dequoting, printf -v turned out slow Message-ID: <20180309132344.GA20986@chaz.gmail.com> Mail-Followup-To: Sebastian Gniazdowski , Zsh hackers list References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) 2018-03-09 07:22:46 +0100, Sebastian Gniazdowski: > Hello > Two scripts: > > - short.txt > Test of quoting, (q)-flag vs. printf -v output '%q ' > result: 35 ms vs. 26.6 sec > > - Q_short.txt – test of dequoting, (Q)-flag vs. eval "str=$quoted" > result: 25 ms vs. 77 ms > > I've compared "printf -v" code to Bash 4.4 and it yields 227 > ms there, so much better than 26.6 sec. So while "Bash can > serialize/deserialize too, let's compare speed of this method" > is interesting thing and I share, performance of "printf -v" > on Zsh is troubling. Any idea from where it comes from and if > it can be improved? [...] I can't reproduce with zsh 5.4.2 (x86_64-debian-linux-gnu) compared with 4.4.18(1)-release (x86_64-pc-linux-gnu). in a en_GB.UTF-8 locale. FWIW, I find: $ time INPUT='ice as"program" pick"$ZPFX/bin/prll_(qer|bfr)" src"prll.sh" make"install PREFIX=$ZPFX"' bash -c 'for ((i = 0; i < 50000; i++)); do printf -v OUTPUT %q "$INPUT"; done' INPUT= bash -c 1.48s user 0.00s system 99% cpu 1.485 total $ time INPUT='ice as"program" pick"$ZPFX/bin/prll_(qer|bfr)" src"prll.sh" make"install PREFIX=$ZPFX"' zsh -c 'for ((i = 0; i < 50000; i++)); do printf -v OUTPUT %q "$INPUT"; done' INPUT= zsh -c 0.83s user 0.14s system 99% cpu 0.979 total What's your version and locale? -- Stephane