from timeit import default_timer as timer import extra1 import extra2 import main_task iterations = 10 def time_main() -> float: start = timer() file = open('schedule.xml', encoding='utf8') contents = file.read() xml_parser = main_task.XmlParser() for i in range(iterations): xml_parser.parse_xml(contents) xml_parser.load_json() end = timer() return end - start def time_extra1() -> float: start = timer() file = open('schedule.xml', encoding='utf8') content = file.read() for i in range(iterations): extra1.xml_to_json(content, True) end = timer() return end - start def time_extra2() -> float: start = timer() file = open('schedule.xml', encoding='utf8') contents = file.read() for i in range(iterations): extra2.xml_to_json(contents) end = timer() return end - start if __name__ == "__main__": print(f'Количество итераций: {iterations}') print(f'Основное задание (без regex и библиотек): {time_main():.4f} секунд') print(f'Доп. задание №1 (с помощью библиотек xmltodict и json): {time_extra1():.4f} секунд') print(f'Доп. задание №2 (с помощью regex): {time_extra2():.4f} секунд')