diff options
author | Charlie Vieth <charlie.vieth@gmail.com> | 2021-03-11 05:34:50 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-11 19:34:50 +0900 |
commit | 5a874ae241af64368e65b667592918b3fdb17177 (patch) | |
tree | ba500615d50512a74ad9c59cd29b0dd0edde4e31 /Makefile | |
parent | f4e1ed25f224d0ebb4e6bd27c4a012a42c1ccfcd (diff) |
Speed up ANSI code processing (#2368)
This commit speeds up the parsing/processing of ANSI escape codes by
roughly 7.5x. The speedup is mostly accomplished by replacing the regex
with dedicated parsing logic (nextAnsiEscapeSequence()) and reducing the
number of allocations in extractColor().
#### Benchmarks
```
name old time/op new time/op delta
ExtractColor-16 4.89µs ± 5% 0.64µs ± 2% -86.87% (p=0.000 n=9+9)
name old speed new speed delta
ExtractColor-16 25.6MB/s ± 5% 194.6MB/s ± 2% +661.43% (p=0.000 n=9+9)
name old alloc/op new alloc/op delta
ExtractColor-16 1.37kB ± 0% 0.31kB ± 0% -77.31% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
ExtractColor-16 48.0 ± 0% 4.0 ± 0% -91.67% (p=0.000 n=10+10)
```
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -73,6 +73,9 @@ test: $(SOURCES) github.com/junegunn/fzf/src/tui \ github.com/junegunn/fzf/src/util +bench: + cd src && SHELL=/bin/sh GOOS= $(GO) test -v -tags "$(TAGS)" -run=Bench -bench=. -benchmem + install: bin/fzf build: @@ -153,4 +156,4 @@ update: $(GO) get -u $(GO) mod tidy -.PHONY: all build release test install clean docker docker-test update +.PHONY: all build release test bench install clean docker docker-test update |