From e99f2d2d9e8d75d1489b0b58989fe7669ebc1566 Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Thu, 23 Mar 2006 18:16:54 +0000
Subject: [PATCH] Add function to report delta time as part of event timing
 functions.

---
 src/slurmctld/proc_req.c | 14 ++++++++++++++
 src/slurmctld/proc_req.h | 10 ++++++++++
 2 files changed, 24 insertions(+)

diff --git a/src/slurmctld/proc_req.c b/src/slurmctld/proc_req.c
index 2043dc510be..a729abedb24 100644
--- a/src/slurmctld/proc_req.c
+++ b/src/slurmctld/proc_req.c
@@ -125,6 +125,20 @@ inline void diff_tv_str(struct timeval *tv1,struct timeval *tv2,
 		info("Warning: Note very large processing time: %s",tv_str); 
 }
 
+/*
+ * diff_tv - return the difference between two times
+ * IN tv1 - start of event
+ * IN tv2 - end of event
+ * RET time in micro-seconds
+ */
+inline long diff_tv(struct timeval *tv1, struct timeval *tv2)
+{
+	long delta_t;
+	delta_t  = (tv2->tv_sec  - tv1->tv_sec) * 1000000;
+	delta_t +=  tv2->tv_usec - tv1->tv_usec;
+	return delta_t;
+}
+
 /*
  * slurmctld_req  - Process an individual RPC request
  * IN/OUT msg - the request message, data associated with the message is freed
diff --git a/src/slurmctld/proc_req.h b/src/slurmctld/proc_req.h
index b0c75d79454..738c2164055 100644
--- a/src/slurmctld/proc_req.h
+++ b/src/slurmctld/proc_req.h
@@ -38,11 +38,13 @@
 #	define START_TIMER	gettimeofday(&tv1, NULL)
 #	define END_TIMER	gettimeofday(&tv2, NULL); \
 				diff_tv_str(&tv1, &tv2, tv_str, 20)
+#	define DELTA_TIMER	diff_tv(&tv1, &tv2)
 #	define TIME_STR 	tv_str
 #else
 #	define DEF_TIMERS	int tv1, tv2, tv_str
 #	define START_TIMER	tv1 = 0
 #	define END_TIMER	tv2 = tv_str = 0
+#	define DELTA_TIMER	0L
 #	define TIME_STR 	""
 #endif
 
@@ -56,6 +58,14 @@
 extern inline void diff_tv_str(struct timeval *tv1,struct timeval *tv2, 
 		char *tv_str, int len_tv_str);
 
+/*
+ * diff_tv - return the difference between two times
+ * IN tv1 - start of event
+ * IN tv2 - end of event
+ * RET time in micro-seconds
+ */
+inline long diff_tv(struct timeval *tv1, struct timeval *tv2);
+
 /*
  * slurmctld_req  - Process an individual RPC request
  * IN/OUT msg - the request message, data associated with the message is freed
-- 
GitLab