Browse Source

Create interpreter, baseline JIT perf tests

jonathanvdc 8 years ago
parent
commit
d25dd6df1f

+ 6 - 0
performance/code/test_harness.alc

@@ -1,10 +1,16 @@
 include "primitives.alh"
+include "jit.alh"
 
 Void function test_main()
 
 Void function main():
+	String config
 	Integer start_time
 	Integer end_time
+	config = input()
+	if (config == "interpreter"):
+		set_jit_enabled(False)
+
 	start_time = time()
 	test_main()
 	end_time = time()

+ 8 - 8
performance/test_fibonacci.py

@@ -3,15 +3,15 @@ import utils
 
 
 class TestFibonacci(unittest.TestCase):
-    # def test_po_fibonacci(self):
-    #     self.fibonacci("PO")
+    def test_interpreter_fibonacci(self):
+        self.fibonacci(utils.OPTIMIZATION_LEVEL_INTERPRETER)
 
-    def test_co_fibonacci(self):
-        self.fibonacci("CO")
+    def test_baseline_jit_fibonacci(self):
+        self.fibonacci(utils.OPTIMIZATION_LEVEL_BASELINE_JIT)
 
-    def fibonacci(self, mode):
+    def fibonacci(self, optimization_level):
         print(
             utils.run_perf_test(
-                ["test_harness.alc", "fibonacci.alc", "primitives.alc"],
-                [20, 0],
-                mode))
+                ["test_harness.alc", "fibonacci.alc", "primitives.alc", "jit.alc"],
+                [20],
+                optimization_level))

+ 8 - 8
performance/test_matrix_create.py

@@ -3,17 +3,17 @@ import utils
 
 
 class TestMatrixCreate(unittest.TestCase):
-    # def test_po_matrix_create(self):
-    #     self.create_matrix("PO")
+    def test_interpreter_matrix_create(self):
+        self.create_matrix(utils.OPTIMIZATION_LEVEL_INTERPRETER)
 
-    def test_co_matrix_create(self):
-        self.create_matrix("CO")
+    def test_baseline_jit_matrix_create(self):
+        self.create_matrix(utils.OPTIMIZATION_LEVEL_BASELINE_JIT)
 
-    def create_matrix(self, mode):
+    def create_matrix(self, optimization_level):
         print(
             utils.run_perf_test(
                 ["test_harness.alc", "matrix.alc",
                  "matrix_create.alc", "primitives.alc",
-                 "random.alc"],
-                [100, 0],
-                mode))
+                 "random.alc", "jit.alc"],
+                [100],
+                optimization_level))

+ 8 - 8
performance/test_matrix_gauss_jordan.py

@@ -3,17 +3,17 @@ import utils
 
 
 class TestMatrixGaussJordan(unittest.TestCase):
-    # def test_po_matrix_gauss_jordan(self):
-    #     self.matrix_gauss_jordan("PO")
+    def test_interpreter_matrix_gauss_jordan(self):
+        self.matrix_gauss_jordan(utils.OPTIMIZATION_LEVEL_INTERPRETER)
 
-    def test_co_matrix_gauss_jordan(self):
-        self.matrix_gauss_jordan("CO")
+    def test_baseline_jit_matrix_gauss_jordan(self):
+        self.matrix_gauss_jordan(utils.OPTIMIZATION_LEVEL_BASELINE_JIT)
 
-    def matrix_gauss_jordan(self, mode):
+    def matrix_gauss_jordan(self, optimization_level):
         print(
             utils.run_perf_test(
                 ["test_harness.alc", "matrix.alc",
                  "matrix_gauss_jordan.alc", "primitives.alc",
-                 "random.alc"],
-                [30, 0],
-                mode))
+                 "random.alc", "jit.alc"],
+                [25],
+                optimization_level))

+ 7 - 2
performance/utils.py

@@ -24,6 +24,9 @@ CURRENT_FOLDER_NAME = "performance"
 
 PORTS = set()
 
+OPTIMIZATION_LEVEL_INTERPRETER = "interpreter"
+OPTIMIZATION_LEVEL_BASELINE_JIT = "baseline-jit"
+
 class ModelverseTerminated(Exception):
     """An exception that tells the user that the Modelverse has terminated."""
     pass
@@ -223,13 +226,15 @@ def run_file_single_output(files, parameters, mode):
        and then collects and returns a single output."""
     return run_file_fixed_output_count(files, parameters, mode, 1)[0]
 
-def run_perf_test(files, parameters, mode, n_iterations=1):
+def run_perf_test(files, parameters, optimization_level, n_iterations=1):
     """Compiles the given sequence of files, feeds them the given input in the given mode,
        and then collects their output. This process is repeated n_iterations times. The
        return value is the average of all outputs."""
     result = 0.0
     for _ in xrange(n_iterations):
-        result += float(run_file_single_output(files, parameters, mode)) / float(n_iterations)
+        result += float(
+            run_file_single_output(
+                files, [optimization_level] + parameters + [0], 'CO')) / float(n_iterations)
     return result
 
 def format_output(output):