]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Print some statistics in perf.sh
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 28 Apr 2010 06:49:18 +0000 (08:49 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 28 Apr 2010 06:57:40 +0000 (08:57 +0200)
perf.sh

diff --git a/perf.sh b/perf.sh
index 62ad1d82793ff050a9694f4b943af88d19286c6f..fdc2904cbfc6e16b9b240f932edb6346c7a4123b 100755 (executable)
--- a/perf.sh
+++ b/perf.sh
@@ -45,6 +45,15 @@ elapsed() {
     perl -e 'use Time::HiRes qw(time); printf("%.3f\n", time - $ARGV[0])' $1
 }
 
+stat() {
+    desc=$1
+    time=$2
+    ref_time=$3
+    perc=$(perl -e "print 100 * $time / $ref_time")
+    factor=$(perl -e "print $ref_time / $time")
+    printf "%-36s %.3f s (%6.2f %%) (%5.2f x)\n" "$desc:" $time $perc $factor
+}
+
 ###############################################################################
 
 if [ -n "$CXX" ]; then
@@ -70,17 +79,20 @@ create_src $n
 echo "Without ccache:"
 t0=$(now)
 compile $n $cxx
-echo "Time: $(elapsed $t0)"
+t_wo=$(elapsed $t0)
+echo "Time: $t_wo"
 
 echo "With ccache, no direct, cache miss:"
 t0=$(now)
 compile $n "$ccache $cxx"
-echo "Time: $(elapsed $t0)"
+t_p_m=$(elapsed $t0)
+echo "Time: $t_p_m"
 
 echo "With ccache, no direct, cache hit:"
 t0=$(now)
 compile $n "$ccache $cxx"
-echo "Time: $(elapsed $t0)"
+t_p_h=$(elapsed $t0)
+echo "Time: $t_p_h"
 
 unset CCACHE_NODIRECT
 rm -rf $CCACHE_DIR
@@ -88,9 +100,18 @@ rm -rf $CCACHE_DIR
 echo "With ccache, direct, cache miss:"
 t0=$(now)
 compile $n "$ccache $cxx"
-echo "Time: $(elapsed $t0)"
+t_d_m=$(elapsed $t0)
+echo "Time: $t_d_m"
 
 echo "With ccache, direct, cache hit:"
 t0=$(now)
 compile $n "$ccache $cxx"
-echo "Time: $(elapsed $t0)"
+t_d_h=$(elapsed $t0)
+echo "Time: $t_d_h"
+
+echo
+stat "Without ccache" $t_wo $t_wo
+stat "With ccache, no direct, cache miss" $t_p_m $t_wo
+stat "With ccache, no direct, cache hit" $t_p_h $t_wo
+stat "With ccache, direct, cache miss" $t_d_m $t_wo
+stat "With ccache, direct, cache hit" $t_d_h $t_wo