From: Karel Zak <kzak@redhat.com>
To: Sami Kerola <kerolasa@iki.fi>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH] ul: enhance command performance
Date: Mon, 1 Jul 2013 14:05:15 +0200 [thread overview]
Message-ID: <20130701120515.GB1946@x2.net.home> (raw)
In-Reply-To: <1372581840-18966-1-git-send-email-kerolasa@iki.fi>
On Sun, Jun 30, 2013 at 09:44:00AM +0100, Sami Kerola wrote:
> Avoid reseting, time after time, the memory which was not used. Effect
> of the change is below in before and after timings.
>
> $ time ./ul </etc/services >/dev/null
> real 0m0.320s
> user 0m0.307s
> sys 0m0.010s
>
> $ time ./ul </etc/services >/dev/null
> real 0m0.068s
> user 0m0.050s
> sys 0m0.017s
Good catch :-)
> @@ -491,11 +491,11 @@ static void initbuf(void)
> if (obuf == NULL) {
> /* First time. */
> obuflen = BUFSIZ;
> - obuf = xmalloc(sizeof(struct CHAR) * obuflen);
> + obuf = xcalloc(obuflen, sizeof(struct CHAR));
> }
>
else
> /* assumes NORMAL == 0 */
> - memset(obuf, 0, sizeof(struct CHAR) * obuflen);
> + memset(obuf, 0, sizeof(struct CHAR) * col);
I think 'maxcol' rather than col is more precise solution ;-)
Applied, thanks.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
prev parent reply other threads:[~2013-07-01 12:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-30 8:44 [PATCH] ul: enhance command performance Sami Kerola
2013-07-01 12:05 ` Karel Zak [this message]
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=20130701120515.GB1946@x2.net.home \
--to=kzak@redhat.com \
--cc=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox