Johan Walles
de4028e7b7
Merge pull request #58 from 89z/master
...
Simplify StyleDefault definition
2021-05-11 15:22:40 +02:00
Steven Penny
f76fd6ddd3
Simplify StyleDefault definition
...
StyleDefault is all zero values, so we can simplify the definition. If that
changes in the future (not likely) we can go back to the old definition method.
Fixes #57
2021-05-11 08:14:15 -05:00
Johan Walles
5e49329110
Split a large function into smaller ones
...
For great readability.
2021-05-08 17:21:08 +02:00
Johan Walles
e3e8be0b8b
CTRL-L isn't a thing any more
...
Since replacing tcell with twin, we now redraw the whole screen every
time, and CTRL-L doesn't do anything.
2021-05-08 15:05:12 +02:00
Johan Walles
5d5ecae7c0
Speed up line counting 4x
...
And improve large file loading performance in the process.
2021-05-08 14:16:38 +02:00
Johan Walles
09ab8a4072
Add a line counting performance benchmark
2021-05-08 13:57:54 +02:00
Johan Walles
78ab63273a
Move some test-only code into *_test.go files
2021-05-08 10:32:04 +02:00
Johan Walles
99d8db63fb
Improve startup interactivity
...
By moving line counting into the background goroutine that consumes the
input stream.
This will make the UI appear faster for large files where line counting
takes time.
2021-05-08 10:26:16 +02:00
Johan Walles
5e847f4cd7
Improve large file reading performance by 10%
...
By reading the file in two passes.
The first pass just counts the lines in the file.
The second pass starts by preallocating the correct number of lines, and
then reads the file.
The whole time saving comes from not having to dynamically resize the
lines slice while reading the file.
2021-05-03 20:33:25 +02:00
Johan Walles
97884d1805
Add a large file benchmark
2021-05-03 19:15:43 +02:00
Johan Walles
f8e45f73e2
Log input stream consumption time
...
At debug level.
2021-05-03 08:08:41 +02:00
Johan Walles
9af12f451c
Move code outside of a lock
2021-05-03 06:44:57 +02:00
Johan Walles
7a66c633ca
Lower memory usage by 10%
...
When loading a 577MB file.
2021-05-02 19:28:51 +02:00
Johan Walles
306442f2b2
Split a line to improve profilability
...
The line is top of the pprof alloc profile, but splitting it might
show which allocation on that line it is that is so common.
2021-05-02 17:36:22 +02:00
Johan Walles
96d26bb97c
Avoid some memory allocations
...
By reusing the same slice for reading all lines from the input file.
2021-05-02 14:47:20 +02:00
Johan Walles
3f4113e7bf
Log trace events on user input
2021-04-29 23:04:12 +02:00
Johan Walles
7c553891f7
Fix a progress message
2021-04-27 07:05:52 +02:00
Johan Walles
e63871ae6a
Make BenchmarkPlainTextSearch() 15+% faster
...
By shortcutting styledStringsFromString() on strings without ESC
characters.
2021-04-26 20:06:08 +02:00
Johan Walles
ef612a5620
Make BenchmarkPlainTextSearch() 50+% faster
...
By using a strings.Builder rather than roll-our-own to build a plain
string.
2021-04-26 08:55:42 +02:00
Johan Walles
860dcd22b4
Make BenchmarkPlainTextSearch() 30% faster
...
By taking a cheap shortcut on strings without backspace characters.
2021-04-26 06:53:30 +02:00
Johan Walles
f5273fc4b3
Make BenchmarkPlainTextSearch() 20% faster
...
Using shortcuts on lines without backspace characters.
2021-04-26 06:40:30 +02:00
Johan Walles
7520c9fc8a
Make BenchmarkPlainTextSearch() 12% faster
...
By optimizing plainification for all-ASCII strings.
2021-04-26 00:24:21 +02:00
Johan Walles
02d66fb31c
Merge branch 'walles/quicksearch'
...
This makes BenchmarkPlainTextSearch() report 30% quicker iterations.
2021-04-25 23:53:25 +02:00
Johan Walles
a5f43e3d2f
Do plaintext like we do cells
...
This loses a lot of the performance improvement originally intended, but
this is still 30% faster than before.
Good step in the right direction.
2021-04-25 23:50:14 +02:00
Johan Walles
d6d428f0ef
Plaintext broken UTF8 as ?
...
Just like we render it, but without the coloring.
2021-04-25 23:38:59 +02:00
Johan Walles
17d8a0372a
Render unprintable characters as highlighted '?'
2021-04-25 23:35:47 +02:00
Johan Walles
7bf168255a
Make test read files like the pager
2021-04-25 21:58:31 +02:00
Johan Walles
e7995bc40f
Use ? to mark unprintable chars in plain text rendering
2021-04-25 20:40:38 +02:00
Johan Walles
1d93f43838
Test: Accept prettified man page bullets
2021-04-25 16:32:00 +02:00
Johan Walles
b17c44af28
Fix off-by-X problems comparing strings
...
Due to byte offsets vs rune offsets.
This fixes some invalid test failures.
2021-04-25 13:21:03 +02:00
Johan Walles
5e59515d3f
Improve new test diagnostics
2021-04-25 12:25:52 +02:00
Johan Walles
7814f6af2f
Add more plaintext-vs-cells verification
2021-04-25 10:08:19 +02:00
Johan Walles
5e2a63dc36
Handle backspace while plaintexting
...
More tests pass now, still not all though.
2021-04-24 23:15:53 +02:00
Johan Walles
66175f02aa
Initial tab expansion
...
Tests still fail, but not as many.
2021-04-24 20:49:58 +02:00
Johan Walles
2c20fc31fe
Special case stripping string formatting
...
Stripping string formatting is on the hot path while searching. This
change makes BenchmarkPlainTextSearch() over 7x faster.
But it also has problems with tab expansion so some tests fail, let's
see how we should handle that.
2021-04-24 17:20:09 +02:00
Johan Walles
c8a8cb4517
Improve memory usage for large files
...
Test:
* Open a 35MB text file
* Search it for some string it doesn't contain
Memory usage before this change: 2.3GB
Memory usage after this change: 0.5GB
The trick is to only provide cells from Lines on demand, since we only
need a few of them when scrolling.
And not storing all of those cells is where the gain in memory usage
comes from.
2021-04-24 16:27:54 +02:00
Johan Walles
c8bc7b0161
Don't highlight files larger than 1MB
...
They make the highlighter just run in the background slowly eating up
memory.
2021-04-24 16:14:30 +02:00
Johan Walles
9e6af21106
Merge pull request #52 from 89z/master
...
DeInit: make output copy friendly
2021-04-24 09:22:14 +02:00
Steven Penny
63082a804d
m/embed-api.go: fix formatting
2021-04-23 19:33:25 -05:00
Steven Penny
374378b979
DeInit: make output copy friendly
...
With DeInit turned off, the current output cannot be usefully copied, as no
newlines are emitted. Close the screen in all cases now, but if DeInit is
disabled, reprint the current buffer with newlines after the screen is closed.
Fixes #51
2021-04-23 19:24:05 -05:00
Johan Walles
d8644ed8e1
Add search performance benchmarks
2021-04-23 22:10:59 +02:00
Johan Walles
60b59c2483
Only install linters when needed
...
This makes most runs of ./test.sh quicker since they don't need to
invoke "go install".
2021-04-23 18:38:40 +02:00
Johan Walles
86ae632f14
Merge branch 'walles/async-highlight'
...
Do highlighting in the background. For large files, or files that are
slow to highlight, this removes the initial highlighting delay.
2021-04-23 06:52:56 +02:00
Johan Walles
232b784428
Fix tests
2021-04-22 22:05:36 +02:00
Johan Walles
c7a26137ef
Merge pull request #50 from 89z/master
...
Use CONIN$ for Windows screen setup
2021-04-22 21:39:14 +02:00
Steven Penny
0f9ae758d5
Use CONIN$ for Windows screen setup
...
Fixes #49
2021-04-22 14:03:22 -05:00
Johan Walles
2c3cc80500
Don't use the plaintext highlighter
2021-04-22 19:31:47 +02:00
Johan Walles
095693eb0b
Wait for highlighting to complete in pager tests
2021-04-22 19:26:29 +02:00
Johan Walles
488aaaab88
Highlight in the background
...
With this change in place, we first quickly get the file contents
without highlighting. Then, when the highlighting is done, the view gets
updated with the highlighted version.
Useful when you're loading long files where highlighting can take time.
2021-04-22 19:26:29 +02:00
Johan Walles
1359a3e558
Merge branch 'walles/test-mod-tidy-install'
...
Fixes #48 by doing "go mod tidy", getting linters using "go mod install"
and bumping to Go 1.16 to get everything working in CI.
Thanks for your research @89z!
2021-04-22 19:23:15 +02:00