Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Inefficient output of results in zio-test #9783

@ioaoue

Description

@ioaoue

When the tests are completed, zio-test outputs their results to the file "target/test-reports-zio/output.json". For output, zio.test.results.ResultFileOps.Json is used, which is implemented inefficiently:

  • The implementation of the write method opens and closes the file on each call. So, the file is reopened as many times as there were events.
  • Before writing the trailing block to the file, the trailing comma is removed from the file contents.
    • To do this, the whole file is loaded into RAM.
    • The same write method is used to write each line of the file. Thus, the number of times a file is reopened increases by the number of lines in it.

Opening a file can be very expensive in some environments. I think all this could be implemented so that the file is opened and closed only once. I see two potential approaches:

  1. Open the file when ResultFileOps.Json is initialized and close it after all events have been written. To eliminate the need to remove the trailing comma, the comma should be written not after every event, but before every event except the first one.
  2. If it is acceptable to store the entire file contents in RAM, then the file can be created after all the JSON data has been generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance and optimization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions