summaryrefslogtreecommitdiff
path: root/benchmarks/ubench/files/patch-timeout-membench.c
blob: f9fa3489af5cb18e2b96e8f62101cf89d9d1587b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--- membench.c.orig	2000-07-31 10:23:27.000000000 -0700
+++ membench.c	2010-11-23 14:20:52.000000000 -0800
@@ -102,7 +102,7 @@
   return i;
 }
 /*****************************************************************************/
-int membench()
+int membench(int membench_time)
 {
   int sv[2],i;
   int d=0;
@@ -114,7 +114,7 @@
       return 0;
     }
   cpu_score=0;
-  alarm(MEMBENCH_TIME);
+  alarm(membench_time);
   switch ( (i=sigsetjmp(env,0xffff)) )
     {
       case 0:
@@ -123,7 +123,7 @@
         for (i=0;i<child_number;i++) kill(child_pid[i],SIGALRM);
         if ( child ) exit(0);
 	close(sv[0]);
-        dlt=(double )cpu_score*(double )itim;
+        dlt=(double )cpu_score * MEMBENCH_TIME * (double )itim / membench_time;
         dlt=dlt/(double )MEMREFSCORE;
         cpu_score=dlt;
 	fprintf(stdout,"Ubench MEM: %8d\n",cpu_score);
@@ -139,13 +139,13 @@
   itim=memcalibrate(MEMREFTIME);
   if ( ONEflag )
     {
-      dlt=itim*(double )MEMBENCH_TIME/(double )MEMREFTIME/(double )MEMREFSCORE;
+      dlt=itim*(double )membench_time/(double )MEMREFTIME/(double )MEMREFSCORE;
       cpu_score=dlt;
       fprintf(stdout,"Ubench Single MEM: %8d (%.2fs)\n",
 	      cpu_score,memload(itim));
       return cpu_score;
     }
-  alarm(MEMBENCH_TIME);
+  alarm(membench_time);
   child_pid[child_number]=fork();
   if ( child_pid[child_number] == -1 )
     {