void (@NotNull Path directory) { var traceJoiner = new StringJoiner("\n"); for (var entry : getPerformanceTrace().entrySet()) { var description = entry.getKey(); var duration = entry.getValue(); var apply = "%s : %d ms.".formatted(description, duration); traceJoiner.add(apply); } try { var file = FileUtil.findSequentNonexistentFile(directory.toFile(), "performance-trace", "txt"); Files.createDirectories(directory); Files.writeString(file.toPath(), traceJoiner.toString()); } catch (IOException e) { throw new RuntimeException(e); } }