<jupyter_start><jupyter_text>This file perform a mini-benchmark of the execution time of the stackedclasses.<jupyter_code>import sys
from os import path
import time
sys.path.append(path.dirname(path.dirname(path.abspath("Test.ipynb"))))
from Controllers_Definition import testcontroller1, testcontroller2, testcontroller3, testcontroller4
from FMLC.triggering import triggering
from FMLC.baseclasses import eFMU
from FMLC.stackedclasses import controller_stack
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Note: Each controller is in a seperate task.<jupyter_code>run_time = []
num_controllers_list = range(5, 76, 5)
#num_controllers_list = [30]
for num_controllers in num_controllers_list:
    # Init
    print(num_controllers)
    controllers = {}
    mapping = {}
    for i in range(num_controllers):
        controllers['controller%s' % i] = {'fun':testcontroller1, 'sampletime':0.25}
        mapping['controller%s_a' % i] = 10
        mapping['controller%s_b' % i] = 4
    ctrl_stack = controller_stack(controllers, mapping, tz=-8, debug=True, parallel=True, timeout=2, workers=200)
    print("Finished Initialization!")
    # Call query_control 6 times
    start_time = time.time()
    for i in range(6):
        ctrl_stack.query_control(time.time())
        # Sleep can be necessary since the run time can be less than the sample time. 
        time.sleep(0.3)
    # Note I subtract the total sleep time from the final run time. 
    print("Done Running!")
    run_time.append(time.time()-start_time)
    ctrl_stack.shutdown()
    print("Shutdown complete!")
plt.plot(num_controllers_list, run_time)
plt.xlabel("Number of Controllers")
plt.ylabel("Runtime (seconds)")
plt.title("Runtime vs #of Controllers")
print(run_time)<jupyter_output>[1.8584399223327637, 1.8711540699005127, 1.8924050331115723, 1.8917582035064697, 1.960773229598999, 1.9435458183288574, 1.961026906967163, 2.016853094100952, 2.004089832305908, 2.1390769481658936, 2.0163791179656982, 2.0044610500335693, 2.080260992050171, 2.2607040405273438, 2.4734079837799072]
{'fraction_non_alphanumeric': 0.104297440849831, 'fraction_numerical': 0.13326895219700627, 'mean_word_length': 5.203592814371257, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '180395', 'license': 'BSD-3-Clause-LBNL', 'n_tokens_mistral': 880, 'n_tokens_neox': 707, 'n_words': 159, 'path': 'examples/ExecutionTime.ipynb', 'repo_name': 'xiaoxstz/FMLC', 'size': '2071'}