]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
perf.py: Enable more accurate measurement of cache hit performance
authorJoel Rosdahl <joel@rosdahl.net>
Fri, 13 Aug 2010 18:38:14 +0000 (20:38 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 14 Aug 2010 19:14:04 +0000 (21:14 +0200)
perf.py

diff --git a/perf.py b/perf.py
index b2e1f2e911d3faf2afb605960ef7f53ce859f832..da29c12600285eab2dc866e6304449e7ad388fc1 100755 (executable)
--- a/perf.py
+++ b/perf.py
@@ -39,6 +39,7 @@ must not contain -c or -o as these options will be added later. Example:
 
 DEFAULT_CCACHE = "./ccache"
 DEFAULT_DIRECTORY = "."
+DEFAULT_HIT_FACTOR = 1
 DEFAULT_TIMES = 30
 
 PHASES = [
@@ -69,6 +70,7 @@ def test(tmp_dir, options, compiler_args, source_file):
 
     compiler_args += ["-c", "-o"]
     extension = splitext(source_file)[1]
+    hit_factor = options.hit_factor
     times = options.times
 
     progress("Creating source code\n")
@@ -137,10 +139,11 @@ def test(tmp_dir, options, compiler_args, source_file):
     recreate_dir(obj_dir)
     progress("Compiling %s\n" % PHASES[2])
     t0 = time()
-    for i in range(times):
-        run(i, True, False)
-        progress(".")
-    result[2] = time() - t0
+    for j in range(hit_factor):
+        for i in range(times):
+            run(i, True, False)
+            progress(".")
+    result[2] = (time() - t0) / hit_factor
     progress("\n")
 
     ###########################################################################
@@ -158,10 +161,11 @@ def test(tmp_dir, options, compiler_args, source_file):
     recreate_dir(obj_dir)
     progress("Compiling %s\n" % PHASES[4])
     t0 = time()
-    for i in range(times):
-        run(i, True, True)
-        progress(".")
-    result[4] = time() - t0
+    for j in range(hit_factor):
+        for i in range(times):
+            run(i, True, True)
+            progress(".")
+    result[4] = (time() - t0) / hit_factor
     progress("\n")
 
     return result
@@ -221,6 +225,11 @@ def main(argv):
         "--hardlink",
         help="use hard links",
         action="store_true")
+    op.add_option(
+        "--hit-factor",
+        help="how many times more to compile the file for cache hits (default: %d)" \
+            % DEFAULT_HIT_FACTOR,
+        type="int")
     op.add_option(
         "--nostats",
         help="don't write statistics",
@@ -242,6 +251,7 @@ def main(argv):
         ccache=DEFAULT_CCACHE,
         compilercheck="mtime",
         directory=DEFAULT_DIRECTORY,
+        hit_factor=DEFAULT_HIT_FACTOR,
         times=DEFAULT_TIMES)
     (options, args) = op.parse_args(argv[1:])
     if len(args) < 2: