visidata icon indicating copy to clipboard operation
visidata copied to clipboard

[main-] remove unneeded reload in batch mode

Open midichef opened this issue 10 months ago • 0 comments

Batch mode (when not replaying commands with -p) is substantially slower to load a file than interactive mode.

seq 2000111 > 2m.tsv
# interactive mode:  quit.vdj is a timing helper script that opens 2m.tsv and immediately quits
=time vd -p quit.vdj
6.41user
# batch mode
=time vd -b 2m.tsv
9.41user

quit.vdj.txt

That's because batch mode runs reload() twice in a row in these two lines: https://github.com/saulpw/visidata/blob/581cdf12b28278aea87ce09f7c32bf8ae1be2f0f/visidata/main.py#L336-L337

vd.push() calls BaseSheet.ensureLoaded() which calls reload(): https://github.com/saulpw/visidata/blob/581cdf12b28278aea87ce09f7c32bf8ae1be2f0f/visidata/sheets.py#L1034 https://github.com/saulpw/visidata/blob/581cdf12b28278aea87ce09f7c32bf8ae1be2f0f/visidata/basesheet.py#L272

This PR removes the unneeded explicit call to reload(), running 2x faster for the special case of no commands.

=time vd -b 2m.tsv
4.73user

midichef avatar Mar 25 '24 06:03 midichef