Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Performance tests of quoting and dequoting, printf -v turned out slow
- X-seq: zsh-workers 42443
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Performance tests of quoting and dequoting, printf -v turned out slow
- Date: Sat, 10 Mar 2018 16:40:54 +0100
- Authentication-results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk
- 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==
- In-reply-to: <etPan.5aa22836.70671812.159ee@zdharma.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author