static void toggleProfiling(@NotNull Project project) {
    CachedValueProfiler.EventConsumer prev = CachedValueProfiler.setEventConsumer(null);
    if (prev == null) {
      CachedValueProfiler.EventConsumer viewer = openDumpViewer(project);
      try {
        File tmpFile = newFile(true);
        CachedValueProfiler.setEventConsumer(new FileEventConsumer(tmpFile, viewer));
      }
      catch (IOException ex) {
        notifyFailure(project, ex);
      }
    }
    else if (prev instanceof FileEventConsumer) {
      File tmpFile = ((FileEventConsumer)prev).file;
      try {
        ((FileEventConsumer)prev).close();
        ((FileEventConsumer)prev).future.get();
        File file = newFile(false);
        FileUtil.rename(tmpFile, file);
        notifySuccess(project, file);
      }
      catch (Exception ex) {
        notifyFailure(project, ex);
        FileUtil.delete(tmpFile);
      }
    }
  }
static void toggleProfiling(@NotNull Project project)