oskusalerma/trelby — pull request #124 by anilgulecha (2012-03-01 04:48:00+00:00)
Title: Undo3

Intel atom netbook. 1.6 Ghz single core.

Opened t2 script, which is ~116 pages. Typed in about 3-4 paragraphs.

With current master:
Resident memory: 35 - 37 Mb.
CPU - 20 %

This branch (buffer set to 100):
Resident memory: 37 Mb
CPU - 20%

The memory usage did nto grow as I made changes, (since about 1 line object per change was being created, which means even the full the buffer took about ~140 line objects).

Looking at these numbers it may make sense to increase the buffer size (default is 50)?

The undo is fast compared to previous implementations because I wrote a simpler version of SequenceMatcher, which has a time complexity (for n items) of O(n). There's also a modification in the second commit which optimises the undo path called most often, and makes the time complexity constant (2 comparisons).