Browse Source

Add a bunch of performance tests

jonathanvdc 8 years ago
parent
commit
43586149ac

+ 119 - 0
performance/test_mvc_model_overwrite.py

@@ -0,0 +1,119 @@
+import unittest
+import utils
+
+all_files = [
+    "core/mini_modify.alc",
+    "core/core_formalism.mvc",
+    "core/core_algorithm.alc",
+    "primitives.alc",
+    "object_operations.alc",
+    "conformance_scd.alc",
+    "library.alc",
+    "transform.alc",
+    "model_management.alc",
+    "ramify.alc",
+    "metamodels.alc",
+    "random.alc",
+    "constructors.alc",
+    "modelling.alc",
+    "compilation_manager.alc",
+]
+
+
+class TestMvCModelOverwrite(unittest.TestCase):
+    def model_overwrite(self, optimization_level):
+        utils.write_total_runtime_to_file(
+            'mvc_model_overwrite', optimization_level,
+            utils.run_correctness_test(all_files, [
+                "root",
+                "root",
+                "root",
+                "model_add",
+                "SimpleClassDiagrams",
+                "Empty",
+                "exit",
+                "model_list_full",
+                "model_modify",
+                "Empty",
+                "instantiate",
+                "Class",
+                "A",
+                "exit",
+                "model_list_full",
+                "model_overwrite",
+                "Empty",
+                "instantiate_node",
+                "",
+                "Class",
+                "B",
+                "instantiate_node",
+                "",
+                "Class",
+                "C",
+                "exit",
+                "model_list_full",
+                "model_modify",
+                "Empty",
+                "list",
+                "exit",
+            ], [
+                "Desired username for admin user?",
+                "Desired password for admin user?",
+                "Please repeat the password",
+                "Passwords match!",
+                "Welcome to the Model Management Interface v2.0!",
+                "Use the 'help' command for a list of possible commands",
+                "Ready for command...",
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                set([
+                    "  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
+                    "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                    "  200  root nobody   Empty : SimpleClassDiagrams",
+                    "  200  root admin   core : CoreFormalism"
+                ]),
+                "Ready for command...",
+                "Which model do you want to modify?",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                "Type to instantiate?",
+                "Name of new element?",
+                "Instantiation successful!",
+                "Please give your command.",
+                "Ready for command...",
+                set([
+                    "  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
+                    "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                    "  200  root nobody   Empty : SimpleClassDiagrams",
+                    "  200  root admin   core : CoreFormalism"
+                ]),
+                "Ready for command...",
+                "Which model to overwrite?",
+                "Waiting for model constructors...",
+                "Model overwrite success!",
+                "Ready for command...",
+                set([
+                    "  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
+                    "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                    "  200  root nobody   Empty : SimpleClassDiagrams",
+                    "  200  root admin   core : CoreFormalism"
+                ]),
+                "Ready for command...",
+                "Which model do you want to modify?",
+                "Model loaded, ready for commands!",
+                "Use 'help' command for a list of possible commands",
+                "Please give your command.",
+                "List of all elements:",
+                set(["  B : Class", "  C : Class"]),
+                "Please give your command.",
+                "Ready for command...",
+            ], optimization_level))
+
+
+utils.define_perf_tests(TestMvCModelOverwrite,
+                        TestMvCModelOverwrite.model_overwrite)

+ 105 - 0
performance/test_mvc_print_upload.py

@@ -0,0 +1,105 @@
+import unittest
+import utils
+
+all_files = [
+    "core/mini_modify.alc",
+    "core/core_formalism.mvc",
+    "core/core_algorithm.alc",
+    "primitives.alc",
+    "object_operations.alc",
+    "conformance_scd.alc",
+    "library.alc",
+    "transform.alc",
+    "model_management.alc",
+    "ramify.alc",
+    "metamodels.alc",
+    "random.alc",
+    "constructors.alc",
+    "modelling.alc",
+    "compilation_manager.alc",
+]
+
+
+class TestMvCPrintUpload(unittest.TestCase):
+    def print_upload(self, optimization_level):
+        utils.write_total_runtime_to_file(
+            'mvc_print_upload', optimization_level,
+            utils.run_correctness_test(all_files, [
+                "root",
+                "root",
+                "root",
+                "model_add",
+                "SimpleClassDiagrams",
+                "PetriNets",
+            ] + utils.get_model_constructor(
+                open("integration/code/pn_runtime.mvc", "r").read()
+            ) + [
+                "model_list_full",
+                "transformation_add_MT_language",
+                "PetriNets",
+                "",
+                "PetriNets_RAM",
+                "model_list_full",
+                "transformation_add_MT",
+                "PetriNets_RAM",
+                "PetriNets",
+                "",
+                "",
+                "PetriNets_Print",
+            ] + utils.get_model_constructor(
+                open("integration/code/pn_print.mvc", "r").read()
+            ) + [
+                "transformation_list_full",
+            ], [
+                "Desired username for admin user?",
+                "Desired password for admin user?",
+                "Please repeat the password",
+                "Passwords match!",
+                "Welcome to the Model Management Interface v2.0!",
+                "Use the 'help' command for a list of possible commands",
+                "Ready for command...",
+                "Creating new model!",
+                "Model type?",
+                "Model name?",
+                "Waiting for model constructors...",
+                "Model upload success!",
+                "Ready for command...",
+                set([
+                    "  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
+                    "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                    "  200  root nobody   PetriNets : SimpleClassDiagrams",
+                    "  200  root admin   core : CoreFormalism"
+                ]),
+                "Ready for command...",
+                "Formalisms to include (terminate with empty string)?",
+                "Name of the RAMified transformation metamodel?",
+                "Ready for command...",
+                set([
+                    "  221  root admin   SimpleClassDiagrams : SimpleClassDiagrams",
+                    "  221  root admin   CoreFormalism : SimpleClassDiagrams",
+                    "  200  root nobody   PetriNets : SimpleClassDiagrams",
+                    "  200  root nobody   __merged_PetriNets_RAM : SimpleClassDiagrams",
+                    "  200  root nobody   PetriNets_RAM : SimpleClassDiagrams",
+                    "  200  root admin   core : CoreFormalism"
+                ]),
+                "Ready for command...",
+                "RAMified metamodel to use?",
+                "Supported metamodels:",
+                set([
+                    "  PetriNets",
+                ]),
+                "",
+                "Which ones do you want to use as source (empty string to finish)?",
+                "Model added as source",
+                "Which ones do you want to use as target (empty string to finish)?",
+                "Name of new transformation?",
+                "Waiting for model constructors...",
+                "Ready for command...",
+                set([
+                    "  200  root nobody   [ModelTransformation] PetriNets_Print : PetriNets_RAM"
+                ]),
+                "Ready for command...",
+            ], optimization_level))
+
+
+utils.define_perf_tests(TestMvCPrintUpload, TestMvCPrintUpload.print_upload)

+ 2 - 2
performance/test_mvc.py

@@ -19,7 +19,7 @@ all_files = [
     "compilation_manager.alc",
 ]
 
-class TestMvC(unittest.TestCase):
+class TestMvCSimulateLarger(unittest.TestCase):
     def transform_add_MT_pn_simulate_larger(self, optimization_level):
         def step_and_print():
             return [
@@ -46,7 +46,7 @@ class TestMvC(unittest.TestCase):
             ]
 
         utils.write_total_runtime_to_file(
-            'test_mvc', optimization_level,
+            'mvc_large', optimization_level,
             utils.run_correctness_test(all_files,
             ["root", "root", "root",
                 "model_add",

+ 5 - 2
performance/utils.py

@@ -399,5 +399,8 @@ def parse_perf_data(file_name):
     with open(file_name, 'r') as perf_file:
         for line in perf_file.readlines():
             test_name, optimization_level, quantity, result = line.strip().split(':')
-            results[quantity][optimization_level].append((test_name, result))
-    return sorted(results.items(), key=operator.itemgetter(1))
+            results[quantity][optimization_level].append((test_name, float(result)))
+    return {
+        quantity: sorted(result_dict.items(), key=operator.itemgetter(0))
+        for quantity, result_dict in results.items()
+    }