[asterisk-commits] mattf: trunk r84115 - /trunk/main/translate.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 28 19:19:16 CDT 2007


Author: mattf
Date: Fri Sep 28 19:19:15 2007
New Revision: 84115

URL: http://svn.digium.com/view/asterisk?view=rev&rev=84115
Log:
Let's use process time instead of wall clock time for show translation

Modified:
    trunk/main/translate.c

Modified: trunk/main/translate.c
URL: http://svn.digium.com/view/asterisk/trunk/main/translate.c?view=diff&rev=84115&r1=84114&r2=84115
==============================================================================
--- trunk/main/translate.c (original)
+++ trunk/main/translate.c Fri Sep 28 19:19:15 2007
@@ -30,6 +30,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/time.h>
+#include <sys/resource.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
@@ -370,8 +371,8 @@
 {
 	int sofar=0;
 	struct ast_trans_pvt *pvt;
-	struct timeval start;
-	struct timeval end;
+	struct rusage start;
+	struct rusage end;
 	int cost;
 
 	if (!seconds)
@@ -389,7 +390,7 @@
 		t->cost = 999999;
 		return;
 	}
-	start = ast_tvnow();
+	getrusage(RUSAGE_SELF, &start);
 	/* Call the encoder until we've processed the required number of samples */
 	while (sofar < seconds * 8000) {
 		struct ast_frame *f = t->sample();
@@ -406,8 +407,9 @@
 			ast_frfree(f);
 		}
 	}
-	end = ast_tvnow();
-	cost = ((end.tv_sec - start.tv_sec)*1000000) + end.tv_usec - start.tv_usec;
+	getrusage(RUSAGE_SELF, &end);
+	cost = ((end.ru_utime.tv_sec - start.ru_utime.tv_sec)*1000000) + end.ru_utime.tv_usec - start.ru_utime.tv_usec;
+	cost += ((end.ru_stime.tv_sec - start.ru_stime.tv_sec)*1000000) + end.ru_stime.tv_usec - start.ru_stime.tv_usec;
 	destroy(pvt);
 	t->cost = cost / seconds;
 	if (!t->cost)




More information about the asterisk-commits mailing list