igt-dev.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Petri Latvala <petri.latvala@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 2/5] lib: Export igt_gettime and igt_time_elapsed
Date: Wed,  8 Aug 2018 14:06:58 +0300	[thread overview]
Message-ID: <20180808110701.12619-3-petri.latvala@intel.com> (raw)
In-Reply-To: <20180808110701.12619-1-petri.latvala@intel.com>

Signed-off-by: Petri Latvala <petri.latvala@intel.com>
---
 lib/igt_core.c | 23 +++++++++++------------
 lib/igt_core.h | 20 ++++++++++++++++++++
 2 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index d3385756..c52c0818 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -403,9 +403,8 @@ void igt_kmsg(const char *format, ...)
 
 #define time_valid(ts) ((ts)->tv_sec || (ts)->tv_nsec)
 
-static double
-time_elapsed(struct timespec *then,
-	     struct timespec* now)
+double igt_time_elapsed(struct timespec *then,
+			struct timespec *now)
 {
 	double elapsed = -1.;
 
@@ -417,7 +416,7 @@ time_elapsed(struct timespec *then,
 	return elapsed;
 }
 
-static int gettime(struct timespec *ts)
+int igt_gettime(struct timespec *ts)
 {
 	memset(ts, 0, sizeof(*ts));
 	errno = 0;
@@ -450,7 +449,7 @@ uint64_t igt_nsec_elapsed(struct timespec *start)
 {
 	struct timespec now;
 
-	gettime(&now);
+	igt_gettime(&now);
 	if ((start->tv_sec | start->tv_nsec) == 0) {
 		*start = now;
 		return 0;
@@ -811,7 +810,7 @@ out:
 	igt_install_exit_handler(common_exit_handler);
 
 	if (!test_with_subtests)
-		gettime(&subtest_time);
+		igt_gettime(&subtest_time);
 
 	for (i = 0; (optind + i) < *argc; i++)
 		argv[i + 1] = argv[optind + i];
@@ -940,7 +939,7 @@ bool __igt_run_subtest(const char *subtest_name)
 
 	_igt_log_buffer_reset();
 
-	gettime(&subtest_time);
+	igt_gettime(&subtest_time);
 	return (in_subtest = subtest_name);
 }
 
@@ -985,15 +984,15 @@ static void exit_subtest(const char *result)
 {
 	struct timespec now;
 
-	gettime(&now);
+	igt_gettime(&now);
 	igt_info("%sSubtest %s: %s (%.3fs)%s\n",
 		 (!__igt_plain_output) ? "\x1b[1m" : "",
-		 in_subtest, result, time_elapsed(&subtest_time, &now),
+		 in_subtest, result, igt_time_elapsed(&subtest_time, &now),
 		 (!__igt_plain_output) ? "\x1b[0m" : "");
 	fflush(stdout);
 	if (stderr_needs_sentinel)
 		fprintf(stderr, "Subtest %s: %s (%.3fs)\n",
-			in_subtest, result, time_elapsed(&subtest_time, &now));
+			in_subtest, result, igt_time_elapsed(&subtest_time, &now));
 
 	igt_terminate_spin_batches();
 
@@ -1484,7 +1483,7 @@ void igt_exit(void)
 		struct timespec now;
 		const char *result;
 
-		gettime(&now);
+		igt_gettime(&now);
 
 		switch (igt_exitcode) {
 			case IGT_EXIT_SUCCESS:
@@ -1501,7 +1500,7 @@ void igt_exit(void)
 		}
 
 		printf("%s (%.3fs)\n",
-		       result, time_elapsed(&subtest_time, &now));
+		       result, igt_time_elapsed(&subtest_time, &now));
 	}
 
 	exit(igt_exitcode);
diff --git a/lib/igt_core.h b/lib/igt_core.h
index aaf1b626..b80e1702 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -928,6 +928,26 @@ extern enum igt_log_level igt_log_level;
 void igt_set_timeout(unsigned int seconds,
 		     const char *op);
 
+/**
+ * igt_gettime:
+ * @ts: current monotonic clock reading
+ *
+ * Reports the current time in the monotonic clock.
+ * Returns: 0 on success, -errno on failure.
+ */
+int igt_gettime(struct timespec *ts);
+
+/**
+ * igt_time_elapsed:
+ * @then: Earlier timestamp
+ * @now: Later timestamp
+ *
+ * Returns: Time between two timestamps in seconds, as a floating
+ * point number.
+ */
+double igt_time_elapsed(struct timespec *then,
+			struct timespec *now);
+
 /**
  * igt_nsec_elapsed:
  * @start: measure from this point in time
-- 
2.14.1

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2018-08-08 11:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-08 11:06 [igt-dev] [PATCH i-g-t 0/5] New test runner to rule them all, v3 Petri Latvala
2018-08-08 11:06 ` [igt-dev] [PATCH i-g-t 1/5] lib: Print subtest starting/ending line to stderr too Petri Latvala
2018-08-08 11:17   ` Chris Wilson
2018-08-08 11:28     ` Petri Latvala
2018-08-08 11:06 ` Petri Latvala [this message]
2018-08-08 11:06 ` [igt-dev] [PATCH i-g-t 3/5] uwildmat: Case-insensitive test selection Petri Latvala
2018-08-08 11:07 ` [igt-dev] [PATCH i-g-t v3 4/5] runner: New test runner Petri Latvala
2018-08-08 11:07 ` [igt-dev] [PATCH i-g-t v4 5/5] runner: Unit tests for the runner Petri Latvala
2018-08-08 11:18 ` [igt-dev] [PATCH i-g-t 0/5] New test runner to rule them all, v3 Arkadiusz Hiler
2018-08-08 12:41 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-08-08 17:35 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2018-06-13 10:07 [igt-dev] [PATCH i-g-t v2 0/5] New runner to rule them all, version 2 Petri Latvala
2018-06-13 10:07 ` [igt-dev] [PATCH i-g-t 2/5] lib: Export igt_gettime and igt_time_elapsed Petri Latvala

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=20180808110701.12619-3-petri.latvala@intel.com \
    --to=petri.latvala@intel.com \
    --cc=igt-dev@lists.freedesktop.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;
as well as URLs for NNTP newsgroup(s).