def _print_performance_stats() -> None: data = performance.read() grouped_data: DefaultDict[str, List[Mapping[ str, Any]]] = collections.defaultdict(list) for row in data: grouped_data[row["name"]].append(row) for name in sorted(grouped_data.keys()): _print_single_performance_stats(name, grouped_data[name]) _print_single_performance_stats("Overall", data)
def test_read_empty(self) -> None: performance.enable() self.assertEqual(performance.read(), [])
def test_write_read_write_read(self) -> None: performance.enable() performance.write({"foo": 1}) self.assertEqual(performance.read(), [{"foo": 1}]) performance.write({"bar": 2}) self.assertEqual(performance.read(), [{"foo": 1}, {"bar": 2}])
def test_read_not_enabled(self) -> None: self.assertEqual(performance.read(), [])