From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 07022138334 for ; Thu, 26 Sep 2019 14:06:53 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EC106E09A8; Thu, 26 Sep 2019 14:06:51 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D42B6E09A8 for ; Thu, 26 Sep 2019 14:06:51 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 589C834B5DC for ; Thu, 26 Sep 2019 14:06:50 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id C5DD97FF for ; Thu, 26 Sep 2019 14:06:47 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1569506062.ae999cf28829aad734b43255941b2c4449fc951b.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qlop.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: ae999cf28829aad734b43255941b2c4449fc951b X-VCS-Branch: master Date: Thu, 26 Sep 2019 14:06:47 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 404019ef-5fcf-414d-836d-857c9f6443d5 X-Archives-Hash: 9466d921236572696c80d5fa14e4dc26 commit: ae999cf28829aad734b43255941b2c4449fc951b Author: Fabian Groffen gentoo org> AuthorDate: Thu Sep 26 13:54:22 2019 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Thu Sep 26 13:54:22 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ae999cf2 qlop: sort average output before display sort the package lists using atom order for some consistency after set usage Signed-off-by: Fabian Groffen gentoo.org> qlop.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/qlop.c b/qlop.c index b75988a..4347699 100644 --- a/qlop.c +++ b/qlop.c @@ -279,6 +279,25 @@ static char *fmt_elapsedtime(struct qlop_mode *flags, time_t e) return _elapsed_buf; } +struct pkg_match { + char id[BUFSIZ]; + depend_atom *atom; + time_t tbegin; + time_t time; + size_t cnt; +}; + +static int +pkg_sort_cb(const void *l, const void *r) +{ + struct pkg_match *pl = *(struct pkg_match **)l; + struct pkg_match *pr = *(struct pkg_match **)r; + depend_atom *al = pl->atom; + depend_atom *ar = pr->atom; + + return atom_compar_cb(al, ar); +} + /* The format of the sync log has changed over time. Old format: @@ -348,14 +367,6 @@ static int do_emerge_log( size_t parallel_emerge = 0; bool all_atoms = false; char afmt[BUFSIZ]; - - struct pkg_match { - char id[BUFSIZ]; - depend_atom *atom; - time_t tbegin; - time_t time; - size_t cnt; - }; struct pkg_match *pkg; struct pkg_match *pkgw; @@ -917,6 +928,7 @@ static int do_emerge_log( DECLARE_ARRAY(avgs); values_set(merge_averages, avgs); + xarraysort(avgs, pkg_sort_cb); array_for_each(avgs, i, pkg) { printf("%s: %s average for %s%zd%s merge%s\n", atom_format(flags->fmt, pkg->atom), @@ -928,6 +940,7 @@ static int do_emerge_log( xarrayfree_int(avgs); values_set(unmerge_averages, avgs); + xarraysort(avgs, pkg_sort_cb); array_for_each(avgs, i, pkg) { printf("%s: %s average for %s%zd%s unmerge%s\n", atom_format(flags->fmt, pkg->atom),