Re: pkgng default schedule... registering a few reasons for
On Thu, Aug 23, 2012 at 03:50:11PM -0400, Kris Moore wrote:
> Well, it was about time I got to doing a benchmark of this anyway :)
> I did quick benchmark of how one of our utilities parses through a list
> of 1k packages on a newer i5 system:
> First test, using /var/db/pkg/<pkg> check we have been doing:
> 0.178s 0:00.31 54.8%
> 0.123s 0:00.26 61.5%
> 0.099s 0:00.15 60.0%
> Second test, using "pkg info <pkg>":
> 5.347s 0:11.41 91.7%
> 5.444s 0:11.52 91.3%
> 5.878s 0:11.32 91.4%
> The pkg info command is quite a bit slower in this case, but 5 seconds
> isn't horrible.
> [snip]
> The only way around It I've found is to do a quick "pkg info" on the
> entire DB, dump that to a list, then begin to grep through that list for
> each item, but it still takes 10~ seconds on the atom. That may be what
> I end up having to do, but it still stinks to go from a half a second
> startup, to 10 seconds each time. Any other ideas on how to do this
> faster with the new pkgng?
Don't use grep: the list is not big enough to make it worth it.
What should work fairly efficiently is to store a list of packages in a
shell variable once and then check each sub-package without external
programs.
list=$(pkg query %n-%v)
for pkgwithversion in ...; do
case $'\n'$list$'\n' in
*$'\n'"$pkgwithversion"$'\n'*) echo yes ;;
*) echo no ;;
esac
done
This does assume that the list does not change during the loop.
Also, instead of
pName=`echo $pkg | rev | cut -d "-" -f 2-25 | rev`
try
pName=${pkg%-*}
and use arithmetic expansion ($((...))) instead of invoking expr where
possible.
--
Jilles Tjoelker
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
討論串 (同標題文章)
完整討論串 (本文為第 12 之 12 篇):