Skip to contentSkip to conversation

Speed up hack

Qemu-devel Vladimir N. Oleynik 1 participant 1 message May 18, 2004 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Hi, Fabrice.

Quoted 2 lines

Can you estimate the speed gains ? I am especially interested by the poll() overhead.

I changed test/sha1.c for see production

-#define BUFSIZE 4096
+#define BUFSIZE 4096*16
+#define TEST 10
+
+#include <sys/time.h>
+#include <unistd.h>

int
main(int argc, char **argv)

 {
     SHA1_CTX ctx;
     unsigned char hash[20], buf[BUFSIZE];
-    int i;
+    int i, tn;
+    struct timeval tv, tv2;
+    int ts, tus;
+    double dt;

+ for(tn = 0; tn < TEST; tn++) {

+       gettimeofday(&tv, NULL);
     	for(i=0;i<BUFSIZE;i++)
-        buf[i] = i;
+               buf[i] = i + tn;
-    printf("SHA1=");
+       gettimeofday(&tv2, NULL);
+       ts = tv2.tv_sec - tv.tv_sec;
+       tus = tv2.tv_usec - tv.tv_usec;
+       dt = 1000000.0*ts;
+       dt += tus;
+       dt /= 1000000.0;
+       printf("dt=%.3f SHA1=", dt);
     	for(i=0;i<20;i++)
         printf("%02x", hash[i]);
     	printf("\n");

+ }

My P4 2.6GHZ give ~ 1 sec per test, my qemu (softmmu) give:
without TICKS_BEFORE_POLL ~ 11.838 sec per test withc TICKS_BEFORE_POLL=100 ~ 11.756 sec per test Hmm. very little different :(
I give ~ 0.02 sec per test if set "static inline" for cpu_get_real_ticks() and qemu_run_timers()
;-)

Quoted 2 lines

For the rest, optimizing DMA_run() would be simpler and more efficient.

May be ;-)

--w
vodz