Skip to content

Optimize generic_list

Michal Vasilek requested to merge optimize-list into master

approximately halves the time schnapps list takes at the cost of being a bit less generic

before:

# time ./schnapps list
    # | Type      | Size        | Date                        | Description
------+-----------+-------------+-----------------------------+------------------------------------
    1 | pre       |   368.00KiB | 2021-08-18 13:13:56 +0200   | Automatic pre-update snapshot (TurrisOS 5.2.4)
    2 | post      |    16.00KiB | 2021-08-18 13:14:03 +0200   | Automatic post-update snapshot (TurrisOS 5.2.4)
    3 | single    |    16.00KiB | 2021-08-18 13:14:28 +0200   | hbs
    4 | pre       |    12.59MiB | 2021-08-18 13:15:26 +0200   | Automatic pre-update snapshot (TurrisOS 5.2.4)
    5 | post      |   464.00KiB | 2021-08-18 13:16:43 +0200   | Automatic post-update snapshot (TurrisOS 5.2.5)
    6 | single    |    96.00KiB | 2021-08-18 14:12:11 +0200   | hbk
    7 | pre       |    57.91MiB | 2021-08-18 14:13:56 +0200   | Automatic pre-update snapshot (TurrisOS 5.2.5)
    8 | post      |     1.34MiB | 2021-08-18 14:22:53 +0200   | Automatic post-update snapshot (TurrisOS 6.0)
    9 | single    |   144.00KiB | 2021-08-19 10:13:58 +0200   | hbd
   10 | rollback  |   200.00KiB | 2021-08-19 10:23:19 +0200   | Rollback to snapshot 6
real    0m 1.51s
user    0m 1.05s
sys     0m 0.32s

after:

# time schnapps list
    # | Type      | Size        | Date                      | Description
------+-----------+-------------+---------------------------+------------------------------------
    1 | pre       |   368.00KiB | 2021-08-18 13:13:56 +0200 | Automatic pre-update snapshot (TurrisOS 5.2.4)
    2 | post      |    16.00KiB | 2021-08-18 13:14:03 +0200 | Automatic post-update snapshot (TurrisOS 5.2.4)
    3 | single    |    16.00KiB | 2021-08-18 13:14:28 +0200 | hbs
    4 | pre       |    12.59MiB | 2021-08-18 13:15:26 +0200 | Automatic pre-update snapshot (TurrisOS 5.2.4)
    5 | post      |   464.00KiB | 2021-08-18 13:16:43 +0200 | Automatic post-update snapshot (TurrisOS 5.2.5)
    6 | single    |    96.00KiB | 2021-08-18 14:12:11 +0200 | hbk
    7 | pre       |    57.91MiB | 2021-08-18 14:13:56 +0200 | Automatic pre-update snapshot (TurrisOS 5.2.5)
    8 | post      |     1.34MiB | 2021-08-18 14:22:53 +0200 | Automatic post-update snapshot (TurrisOS 6.0)
    9 | single    |   144.00KiB | 2021-08-19 10:13:58 +0200 | hbd
   10 | rollback  |   200.00KiB | 2021-08-19 10:23:19 +0200 | Rollback to snapshot 6
real    0m 0.58s
user    0m 0.24s
sys     0m 0.13s

The output should be the same with the exception of removing the two trailing spaces from the end of Date, is there a reason why they should be left there?

Merge request reports