PERFORCE change 166220 for review

Zhao Shuai zhaoshuai at FreeBSD.org
Sat Jul 18 08:49:41 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=166220

Change 166220 by zhaoshuai at zhaoshuai on 2009/07/18 08:48:39

	add some comment in the benchmark program.

Affected files ...

.. //depot/projects/soc2009/fifo/fifo_test/performance/benchmark.c#2 edit
.. //depot/projects/soc2009/fifo/fifo_test/performance/runme.sh#3 edit

Differences ...

==== //depot/projects/soc2009/fifo/fifo_test/performance/benchmark.c#2 (text+ko) ====

@@ -56,21 +56,21 @@
 		goto error1;
 	}
 	
-	if (pid > 0) { /* producer */
+	if (pid > 0) { /* parent as producer */
 		for (i = 0 ; i < array_size; i++)
 			msg_array[i] = i;
 
+		/* record the start time */
 		gettimeofday(&start_time, NULL);
-
 		write(fd, msg_array, msg_size * num_msgs);
-	
 		wait(NULL);
-
+		/* record the end time */
 		gettimeofday(&end_time, NULL);
+		/* caculate the time we use(in microseconds) */
 		time = 1000000 * (end_time.tv_sec - start_time.tv_sec) 
 			+ (end_time.tv_usec - start_time.tv_usec);
 		printf("%u", time);
-	} else { /* consumer */
+	} else { /* child as consumer */
 		while (total_read < msg_size * num_msgs) {
 			nread = read(fd, consumer_buf + total_read / sizeof(int), msg_size * num_msgs);
 			for (i = total_read / sizeof(int); i < nread / sizeof(int); i++)

==== //depot/projects/soc2009/fifo/fifo_test/performance/runme.sh#3 (text+ko) ====

@@ -2,30 +2,30 @@
 
 if [ ! -e benchmark ] 
 then
-    echo "can't find the benchmark program!"
-    exit
+	echo "can't find the benchmark program, build it first!"
+	exit
 fi
 
 echo -ne "\t"
 for num_msg in 1 10 100 1000 10000 100000
 do
-    echo -ne "${num_msg}\t"
+	echo -ne "${num_msg}\t"
 done
 echo ""
 
 for msg_size in 64 128 256 512 1024 2048 4096
 do
-    echo -ne "${msg_size}B\t"
-    for num_msg in 1 10 100 1000 10000 100000
-    do
-	sum=0
-	for ((i = 0; i < 10; i++))
+	echo -ne "${msg_size}B\t"
+	for num_msg in 1 10 100 1000 10000 100000
 	do
-	    time=`./benchmark $msg_size $num_msg`
-	    sum=$(($time + $sum))
+		sum=0
+		for ((i = 0; i < 10; i++))
+		do
+			time=`./benchmark $msg_size $num_msg`
+			sum=$(($time + $sum))
+		done
+		avarage_time=$(($sum / 10))
+		echo -ne "${avarage_time}us\t"
 	done
-	avarage_time=$(($sum / 10))
-	echo -ne "${avarage_time}ns\t"
-    done
-    echo ""
+	echo ""
 done


More information about the p4-projects mailing list