Skip to contentSkip to conversation

perf record: remove unneeded gettimeofday() call

BUGFIX Russ Anderson 1 participant 2 messages May 18, 2010 – May 21, 2010 perf events

lore
Share & tools
lore
#0 lore raw

Perf record repeatedly calls gettimeofday() which adds noise to the performance measurements. Since gettimeofday() is only used for the error printf, delete it.

---
 tools/perf/builtin-record.c |   17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
tools/perf/builtin-record.c +1 -16
Index: linux/tools/perf/builtin-record.c
===================================================================
@@ -64,9 +64,6 @@ static bool			multiplex			=  false;
 static int			multiplex_fd			=     -1;
 
 static long			samples				=      0;
-static struct timeval		last_read;
-static struct timeval		this_read;
-
 static u64			bytes_written			=      0;
 
 static struct pollfd		*event_array;
@@ -146,8 +143,6 @@ static void mmap_read(struct mmap_data *
 	void *buf;
 	int diff;
 
-	gettimeofday(&this_read, NULL);
-
 	/*
 	 * If we're further behind than half the buffer, there's a chance
 	 * the writer will bite our tail and mess up the samples under us.
@@ -158,23 +153,13 @@ static void mmap_read(struct mmap_data *
 	 */
 	diff = head - old;
 	if (diff < 0) {
-		struct timeval iv;
-		unsigned long msecs;
-
-		timersub(&this_read, &last_read, &iv);
-		msecs = iv.tv_sec*1000 + iv.tv_usec/1000;
-
-		fprintf(stderr, "WARNING: failed to keep up with mmap data."
-				"  Last read %lu msecs ago.\n", msecs);
-
+		fprintf(stderr, "WARNING: failed to keep up with mmap data\n");
 		/*
 		 * head points to a known good entry, start there.
 		 */
 		old = head;
 	}
 
-	last_read = this_read;
-
 	if (old != head)
 		samples++;
 
Signature · 2 lines
Russ Anderson, OS RAS/Partitioning Project Lead  
SGI - Silicon Graphics Inc          [email protected]
#1 lore raw
Commit-ID:  ef365cefbc53d8674a18520a1d4c2e5590127299
Gitweb:     http://git.kernel.org/tip/ef365cefbc53d8674a18520a1d4c2e5590127299
Author:     Russ Anderson <[email protected]>
AuthorDate: Tue, 18 May 2010 17:52:40 -0500
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 20 May 2010 21:53:58 -0300

perf record: remove unneeded gettimeofday() call

Perf record repeatedly calls gettimeofday() which adds noise to the performance measurements. Since gettimeofday() is only used for the error printf, delete it.

Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
LKML-Reference: <[email protected]>

---
 tools/perf/builtin-record.c |   17 +----------------
 1 files changed, 1 insertions(+), 16 deletions(-)
tools/perf/builtin-record.c +1 -16
index 66b8ecd..e672269 100644
@@ -65,9 +65,6 @@ static bool			multiplex			=  false;
 static int			multiplex_fd			=     -1;
 
 static long			samples				=      0;
-static struct timeval		last_read;
-static struct timeval		this_read;
-
 static u64			bytes_written			=      0;
 
 static struct pollfd		*event_array;
@@ -147,8 +144,6 @@ static void mmap_read(struct mmap_data *md)
 	void *buf;
 	int diff;
 
-	gettimeofday(&this_read, NULL);
-
 	/*
 	 * If we're further behind than half the buffer, there's a chance
 	 * the writer will bite our tail and mess up the samples under us.
@@ -159,23 +154,13 @@ static void mmap_read(struct mmap_data *md)
 	 */
 	diff = head - old;
 	if (diff < 0) {
-		struct timeval iv;
-		unsigned long msecs;
-
-		timersub(&this_read, &last_read, &iv);
-		msecs = iv.tv_sec*1000 + iv.tv_usec/1000;
-
-		fprintf(stderr, "WARNING: failed to keep up with mmap data."
-				"  Last read %lu msecs ago.\n", msecs);
-
+		fprintf(stderr, "WARNING: failed to keep up with mmap data\n");
 		/*
 		 * head points to a known good entry, start there.
 		 */
 		old = head;
 	}
 
-	last_read = this_read;
-
 	if (old != head)
 		samples++;