Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>,
	Tvrtko Ursulin <tursulin@ursulin.net>,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH 3/4] gputop: Allow to limit number of executions
Date: Wed,  1 May 2024 12:33:02 -0500	[thread overview]
Message-ID: <20240501173303.115737-4-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20240501173303.115737-1-lucas.demarchi@intel.com>

Add argument to limit number of executions, similar to the one accepted
by `top`. This allows testing changes and optimizations more easily.

Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
---
 tools/gputop.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/tools/gputop.c b/tools/gputop.c
index 481e79753..1ac382a7e 100644
--- a/tools/gputop.c
+++ b/tools/gputop.c
@@ -293,6 +293,7 @@ static void clrscr(void)
 }
 
 struct gputop_args {
+	long n_iter;
 };
 
 static void help(void)
@@ -301,19 +302,22 @@ static void help(void)
 	       "\t%s [options]\n\n"
 	       "Options:\n"
 	       "\t-h, --help                show this help\n"
+	       "\t-n, --iterations =NUMBER  number of executions\n"
 	       , program_invocation_short_name);
 }
 
 static int parse_args(int argc, char * const argv[], struct gputop_args *args)
 {
-	static const char cmdopts_s[] = "h";
+	static const char cmdopts_s[] = "hn:";
 	static const struct option cmdopts[] = {
 	       {"help", no_argument, 0, 'h'},
+	       {"iterations", required_argument, 0, 'n'},
 	       { }
 	};
 
 	/* defaults */
 	memset(args, 0, sizeof(*args));
+	args->n_iter = -1;
 
 	for (;;) {
 		int c, idx = 0;
@@ -323,6 +327,9 @@ static int parse_args(int argc, char * const argv[], struct gputop_args *args)
 			break;
 
 		switch (c) {
+		case 'n':
+			args->n_iter = strtol(optarg, NULL, 10);
+			break;
 		case 'h':
 			help();
 			return 0;
@@ -342,6 +349,7 @@ int main(int argc, char **argv)
 	struct igt_drm_clients *clients = NULL;
 	int con_w = -1, con_h = -1;
 	int ret;
+	long n;
 
 	ret = parse_args(argc, argv, &args);
 	if (ret < 0)
@@ -349,13 +357,15 @@ int main(int argc, char **argv)
 	if (!ret)
 		return EXIT_SUCCESS;
 
+	n = args.n_iter;
+
 	clients = igt_drm_clients_init(NULL);
 	if (!clients)
 		exit(1);
 
 	igt_drm_clients_scan(clients, NULL, NULL, 0, NULL, 0);
 
-	for (;;) {
+	while (n != 0) {
 		struct igt_drm_client *c, *prevc = NULL;
 		int i, engine_w = 0, lines = 0;
 
@@ -381,6 +391,8 @@ int main(int argc, char **argv)
 			printf("\n");
 
 		usleep(period_us);
+		if (n > 0)
+			n--;
 	}
 
 	igt_drm_clients_free(clients);
-- 
2.45.0


  parent reply	other threads:[~2024-05-01 17:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-01 17:32 [PATCH 0/4] Minor gputop improvements Lucas De Marchi
2024-05-01 17:33 ` [PATCH 1/4] gputop: print percentage number Lucas De Marchi
2024-05-07 18:22   ` Kamil Konieczny
2024-05-01 17:33 ` [PATCH 2/4] gputop: Add option parsing Lucas De Marchi
2024-05-07 18:24   ` Kamil Konieczny
2024-05-01 17:33 ` Lucas De Marchi [this message]
2024-05-07 18:26   ` [PATCH 3/4] gputop: Allow to limit number of executions Kamil Konieczny
2024-05-01 17:33 ` [PATCH 4/4] gputop: Allow to set delay interval Lucas De Marchi
2024-05-07 18:29   ` Kamil Konieczny
2024-05-01 18:17 ` ✓ CI.xeBAT: success for Minor gputop improvements Patchwork
2024-05-01 18:23 ` ✓ Fi.CI.BAT: " Patchwork
2024-05-01 19:15 ` ✗ CI.xeFULL: failure " Patchwork
2024-05-01 19:42 ` ✗ Fi.CI.IGT: " Patchwork
2024-05-08 15:57 ` [PATCH 0/4] " Lucas De Marchi

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=20240501173303.115737-4-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=tursulin@ursulin.net \
    --cc=umesh.nerlige.ramappa@intel.com \
    /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