Re: [PATCH] ul: enhance command performance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux