Skip to content

Range#setValue/setValues is very slow for large sheet (100K rows) #103

@thestrox

Description

@thestrox

Version
SODS 1.8.2

Problem

  • Range#setValue/setValues is very slow.
  • Reproduce using:
  static void main() throws IOException {
    int rows = 100000;
    int columns = 1;
    String[][] data = new String[rows][columns];
    for (int i = 0; i < rows; i++) {
      for (int j = 0; j < columns; j++) {
        data[i][j] = i + ";" + j;
      }
    }
    SpreadSheet out = new SpreadSheet();
    Sheet sheet = new Sheet("Sheet1", rows, columns);
    out.appendSheet(sheet);
    long startNano = System.nanoTime();
    sheet.getDataRange().setValues(data);
    double endNano = (double) (System.nanoTime() - startNano) / 1_000_000_000;
    System.out.println("Time: " + endNano);
    out.save(Path.of("testExport.ods").toFile());
  }
  • In my test: the Range.setValues() takes around 22 sec with Sheet#getIndexDelete being the hotspot with 94.6% time invested on it, and only 3.4% for saving the file.

Expected

  • I would expect this to be significantly faster than current At the moment, the performance becomes exponentially worse as the row count increases (takes around 125 sec for 200K rows) making large file processing not possible.
  • I thought using Range.setValues could give performance boost compare to Range.setValue, but there is no significant difference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions