[ofa-general] [PATCH] opensm/osm_log: osl_log() speedup

Sasha Khapyorsky sashak at voltaire.com
Wed Jul 9 15:31:32 PDT 2008


Move all calculations under log level check. This speeds up osm_log()
execution time when log level doesn't match in 10-100 times.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/opensm/osm_log.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/opensm/opensm/osm_log.c b/opensm/opensm/osm_log.c
index e1bb647..d4118b1 100644
--- a/opensm/opensm/osm_log.c
+++ b/opensm/opensm/osm_log.c
@@ -107,7 +107,6 @@ void osm_log(IN osm_log_t * const p_log,
 	char buffer[LOG_ENTRY_SIZE_MAX];
 	va_list args;
 	int ret;
-
 #ifdef WIN32
 	SYSTEMTIME st;
 	uint32_t pid = GetCurrentThreadId();
@@ -117,11 +116,6 @@ void osm_log(IN osm_log_t * const p_log,
 	struct tm result;
 	uint64_t time_usecs;
 	uint32_t usecs;
-
-	time_usecs = cl_get_time_stamp();
-	tim = time_usecs / 1000000;
-	usecs = time_usecs % 1000000;
-	localtime_r(&tim, &result);
 #endif				/* WIN32 */
 
 	/* If this is a call to syslog - always print it */
@@ -165,6 +159,10 @@ _retry:
 		    st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
 		    pid, verbosity, buffer);
 #else
+	time_usecs = cl_get_time_stamp();
+	tim = time_usecs / 1000000;
+	usecs = time_usecs % 1000000;
+	localtime_r(&tim, &result);
 	pid = pthread_self();
 _retry:
 	ret =
-- 
1.5.5.1.178.g1f811




More information about the general mailing list