protected void measureUndo(IFile file) throws PartInitException {
    AbstractTextEditor editor = (AbstractTextEditor) EditorTestHelper.openInEditor(file, true);
    editor.showChangeInformation(
        false); // TODO: remove when undo does no longer trigger timing issue

    IAction selectAll = editor.getAction(ITextEditorActionConstants.SELECT_ALL);
    IAction shiftRight = editor.getAction(ITextEditorActionConstants.SHIFT_RIGHT);
    IAction undo = editor.getAction(ITextEditorActionConstants.UNDO);
    int warmUpRuns = getWarmUpRuns();
    int measuredRuns = getMeasuredRuns();
    for (int i = 0; i < warmUpRuns + measuredRuns; i++) {
      runAction(selectAll);
      runAction(shiftRight);
      sleep(5000);
      EditorTestHelper.runEventQueue();
      if (i >= warmUpRuns) fPerformanceMeter.start();
      runAction(undo);
      if (i >= warmUpRuns) fPerformanceMeter.stop();
      sleep(
          5000); // NOTE: runnables posted from other threads, while the main thread waits here, are
                 // not measured at all
    }
    fPerformanceMeter.commit();
    assertPerformance(fPerformanceMeter);
  }
 private void measure(PerformanceMeter performanceMeter, int runs) throws Exception {
   IPackagesViewPart view =
       (IPackagesViewPart)
           EditorTestHelper.getActivePage()
               .findViewReference(EditorTestHelper.PACKAGE_EXPLORER_VIEW_ID)
               .getView(false);
   IAction action =
       ((IViewSite) view.getSite()).getActionBars().getGlobalActionHandler(FORMAT_ACTION_ID);
   boolean wasEnabled = EditorTestHelper.setDialogEnabled(FORMAT_DIALOG_ID, false);
   StructuredSelection selection =
       new StructuredSelection(
           JavaCore.create(ResourceTestHelper.getProject(TextPluginTestSetup.PROJECT)));
   for (int i = 0; i < runs; i++) {
     performanceMeter.start();
     ((SelectionDispatchAction) action).run(selection);
     performanceMeter.stop();
     TextPluginTestSetup.createProjectFromZip();
   }
   EditorTestHelper.setDialogEnabled(FORMAT_DIALOG_ID, wasEnabled);
 }
 private void runAction(IAction action) {
   action.run();
   EditorTestHelper.runEventQueue();
 }
 protected void tearDown() throws Exception {
   super.tearDown();
   EditorTestHelper.closeAllEditors();
   fPerformanceMeter.dispose();
 }
 protected void setUp() throws Exception {
   super.setUp();
   fPerformanceMeter = createMeter();
   EditorTestHelper.runEventQueue();
 }