zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-workers@zsh.org
Subject: Re: Performance tests of quoting and dequoting, printf -v turned out slow
Date: Sat, 10 Mar 2018 16:40:54 +0100	[thread overview]
Message-ID: <19380.1520696454@thecus> (raw)
In-Reply-To: <etPan.5aa22836.70671812.159ee@zdharma.org>

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


  parent reply	other threads:[~2018-03-11  3:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-09  6:22 Sebastian Gniazdowski
2018-03-09 13:23 ` Stephane Chazelas
     [not found] ` <etPan.5aa28b1e.77e79f33.159ee@AirmailxGenerated.am>
2018-03-09 13:39   ` Sebastian Gniazdowski
2018-03-09 14:53     ` Stephane Chazelas
2018-03-10  8:36       ` Sebastian Gniazdowski
2018-03-10 15:03         ` Stephane Chazelas
     [not found]         ` <etPan.5aa3f656.1efba338.159ee@AirmailxGenerated.am>
2018-03-10 16:53           ` Sebastian Gniazdowski
2018-03-10 15:40 ` Oliver Kiddle [this message]
2018-03-11  8:33   ` Bart Schaefer
2018-03-13 11:28     ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19380.1520696454@thecus \
    --to=okiddle@yahoo.co.uk \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).