Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8118492

TableView: Performance degrades when resetting content

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7u6
    • 7u6
    • javafx
    • Mac OS X (but it probably happens everywhere)

      Add this to HelloTableView.Java:

              tableView.setOnMouseReleased(new EventHandler<MouseEvent>() {
                  public void handle(MouseEvent t) {
                      if (t.getClickCount() == 3) {
                          System.out.println("resetting data...");
                          long t0 = System.currentTimeMillis();
                          ObservableList<List<Double>> empty = FXCollections.observableArrayList();
                          tableView.setItems(empty);
                          bigData.clear();
                          getLines(bigData);
                          tableView.setItems(bigData);
                          long t1 = System.currentTimeMillis();
                          System.out.println("Done: " + (t1 - t0));
                      }
                  }
              });

      The code attempts to set empty items into the table then set new items to avoid the code of updating each item in place (whether there is a cost here or not is not the issue).

      0) Run HelloTableView
      1) Click on 'Performance Test'
      2) Triple click on a table item
      3) Triple click on a table item again
      4) Triple click on a table item once more
      5) Setting the table contents gets slower each time

      Here is the output:

      resetting data...
      Done: 12
      resetting data...
      Done: 2682
      resetting data...
      Done: 5211

            jgiles Jonathan Giles
            snorthov Steve Northover (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: