Fixed #43 : BnfNodeParser: I can recognize when multiple level of ISA

Fixed #44 : BnfNodeParser: I must simplify results when multiple levels of ISA
Fixed #45 : Dynamic variables cannot be parsed at restart
Fixed #46 : Concepts variables values are transformed into list by default
Fixed #47 : SheerkaAdmin. Add min, max, mean time when restoring files
This commit is contained in:
2021-03-08 17:35:30 +01:00
parent bd8e027827
commit 031bd0274e
20 changed files with 303 additions and 33 deletions
+24 -5
View File
@@ -78,6 +78,7 @@ class SheerkaAdmin(BaseService):
def restore_from_file(file_name):
_nb_lines, _nb_instructions, _nb_lines_in_error = 0, 0, 0
_min_time, _max_time = None, None
file_path = path.join(path.dirname(sys.argv[0]), file_name)
if not path.exists(file_path):
print(f"\u001b[31mFile '{file_path}' is not found !\u001b[0m")
@@ -90,11 +91,15 @@ class SheerkaAdmin(BaseService):
if line.startswith("#import "):
to_import = "_concepts_" + line[8:] + ".txt"
print(f"Importing {to_import}")
print(f" ==== Importing {to_import} ==== ")
res = restore_from_file(to_import)
_nb_lines += res[0]
_nb_instructions += res[1]
_nb_lines_in_error += res[2]
if _min_time is None or res[3] < _min_time:
_min_time = res[3]
if _max_time is None or res[4] > _max_time:
_max_time = res[4]
continue
if line == "" or line.startswith("#"):
@@ -102,12 +107,20 @@ class SheerkaAdmin(BaseService):
print(line)
_nb_instructions += 1
stop_watch = time.time_ns()
res = self.sheerka.evaluate_user_input(line)
user_input_elapsed = time.time_ns() - stop_watch
if _min_time is None or user_input_elapsed < _min_time:
_min_time = user_input_elapsed
if _max_time is None or user_input_elapsed > _max_time:
_max_time = user_input_elapsed
if len(res) > 1 or not res[0].status:
_nb_lines_in_error += 1
print("\u001b[31mError detected !\u001b[0m")
return _nb_lines, _nb_instructions, _nb_lines_in_error
return _nb_lines, _nb_instructions, _nb_lines_in_error, _min_time, _max_time
if not concept_file.startswith("_concepts"):
concept_file = f"_concepts_{concept_file}.txt"
@@ -119,7 +132,7 @@ class SheerkaAdmin(BaseService):
enable_process_return_values_previous_value = self.sheerka.enable_process_return_values
self.sheerka.enable_process_return_values = False
nb_lines, nb_instructions, nb_lines_in_error = restore_from_file(concept_file)
nb_lines, nb_instructions, nb_lines_in_error, min_time, max_time = restore_from_file(concept_file)
self.sheerka.enable_process_return_values = enable_process_return_values_previous_value
self.sheerka.save_execution_context = True
@@ -128,8 +141,13 @@ class SheerkaAdmin(BaseService):
nano_sec = stop - start
dt = nano_sec / 1e6
elapsed = f"{dt} ms" if dt < 1000 else f"{dt / 1000} s"
print(f"Imported {nb_lines} line(s) in {elapsed}.")
elapsed = f"{dt:.3f} ms" if dt < 1000 else f"{dt / 1000:.3f} s"
min_str = f"{min_time / 1e6:.3f} ms"
max_str = f"{max_time / 1e6:.3f} ms"
mean_time = dt / nb_lines
mean_str = f"{mean_time:.3f} ms" if mean_time < 1000 else f"{mean_time / 1000:.3f} s"
print(f"Imported {nb_lines} line(s) in {elapsed}. min={min_str}, max={max_str}, mean={mean_str}")
print(f"{nb_instructions} instruction(s).")
if nb_lines_in_error > 0:
print(f"\u001b[31m{nb_lines_in_error} errors(s) found.\u001b[0m")
@@ -153,6 +171,7 @@ class SheerkaAdmin(BaseService):
"key": item.key,
"definition": item.get_metadata().definition,
"type": item.get_metadata().definition_type,
"hash": item.get_definition_hash(),
"body": item.get_metadata().body,
"where": item.get_metadata().where,
"pre": item.get_metadata().pre,