From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12047 invoked by alias); 11 Mar 2018 03:48:20 -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: 42443 Received: (qmail 27287 invoked by uid 1010); 11 Mar 2018 03:48:20 -0000 X-Qmail-Scanner-Diagnostics: from park01.gkg.net 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(205.235.26.22):SA:0(-1.4/5.0):. Processed in 1.627388 secs); 11 Mar 2018 03:48:20 -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.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_PASS,T_DKIM_INVALID,T_RP_MATCHES_RCVD autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: SRS0=SNP8=GB=yahoo.co.uk=okiddle@bounces.park01.gkg.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Virus-Scanned: by amavisd-new at gkg.net Authentication-Results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1520739608; bh=z/mE0JstnlxuVBhbZ6NVDxFmnX9HMq8S6jHC0LEvfbc=; h=From:References:To:Subject:Date:From:Subject; b=ER5VjWa5Ds3gn36N9aH2KGfzCmi5ebwpA3ICNs/cJ+GxoKH9wFovzb2Y5V1wXMtinxlStBvkhBUxYrtUa7z5WgbVcKlM6zriHoIQlLTu4ew2ibggRfApkvy45hv+Kz6H/kY8/+mQQOYMp2zwhs/dOPyy1xQAGpKVYMdQAaZL0la+o8t+fWHw4AE9OZEfDYoP2+wehkaHeWoBXshfdCt+UqvXF6C4djKOLQv75xyivQhU9nH8DBbHvwy+jBBhw4z+vXcB4GNdfM4GnZjNGLOzXAeJwPTkMe9Q7TjOFNJiHX6hS5h5Twok9QUszv2jHH2j6liEdgmsrPEhzgP4v/yd8w== X-YMail-OSG: 2esV5QkVM1lBBgAPyhCAQtpiREs1XAOUEvUj9ILvSagqtIH6ohmG8SabtP6BR1y Uq0A6vXbFTazI3dTeyNpwDt9U1CX1EpBNa67y9Wl0eZCXLTgG8Re8XCTVNi2IF2N4pAb1JjM90eF UrRIDV3pBMrDke_kVdGXRhLvfEw1QKzQbxOi7YF_0W7Z9qj.z.1NecWJS7kqGhkzV5XztXTNeOAZ RGj12v7eolesoEocXH5uX8hcDysGP.H6ieEXO6QfpJ15O2gxGt79dwkEV5t_0V0lRX5w8EMryk08 rdTgz_Xlfq.J39zRZ9ditVZrnFEg0A0jtDYoiTalLeKEJBlZBnxMQzjdhNrB4FHonZ2s_V5stoGg L3zsPfJhyRSqudabviKoGQ6zx8frEUn.ATNOY_IvXiPBFgROv6VNZQQWYIyxhMUg0.26JSE4EQeh cRs8jNpvpjjzO7fZ.B6ucCFuq5MW5l7tseinZgrS9Qckb8cRbDBU6iUMAgXNLjhNOwCKsDsZb7uG qOTYPYpsmCg-- In-reply-to: From: Oliver Kiddle References: To: zsh-workers@zsh.org Subject: Re: Performance tests of quoting and dequoting, printf -v turned out slow MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <19379.1520696454.1@thecus> Date: Sat, 10 Mar 2018 16:40:54 +0100 Message-ID: <19380.1520696454@thecus> Sebastian Gniazdowski wrote: > Two scripts: > > - short.txt > Test of quoting, (q)-flag vs. printf -v output '%q ' > result: 35 ms vs. 26.6 sec I can't reproduce speeds that bad from printf -v. I get a factor of 4 at most vs. (q). What may affect things is whether or not zsh was built to use open_memstream from libc. FreeBSD and GNU libc have open_memstream. If you're using some other OS or an alternative libc on Linux it might be using a temporary file. Having /tmp on tmpfs may help. Rearranging printf to use sprintf() might make it faster but calculating suitable buffer sizes is not necessarily easy given that the format is essentially arbitrary. It was originally written without printf -v being a feature: print -s and -z combined with -f were never going to be performance critical. Being able to do printf to a stdio stream keeps the code simpler. Oliver