diff options
| author | Junegunn Choi <junegunn.c@gmail.com> | 2015-08-02 14:00:18 +0900 |
|---|---|---|
| committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-08-02 14:00:18 +0900 |
| commit | 0ea66329b84cc6e4f8ff61ee99c00bb238070247 (patch) | |
| tree | 72c3bc62ec491246390b56b2aac5b33645839503 /src/chunklist_test.go | |
| parent | 634670e3ea51a2fa1498a3de0c074b819828e2d8 (diff) | |
| download | fzf-0ea66329b84cc6e4f8ff61ee99c00bb238070247.tar.gz | |
Performance tuning - eager rune array conversion
> wc -l /tmp/list2
2594098 /tmp/list2
> time cat /tmp/list2 | fzf-0.10.1-darwin_amd64 -fqwerty > /dev/null
real 0m5.418s
user 0m10.990s
sys 0m1.302s
> time cat /tmp/list2 | fzf-head -fqwerty > /dev/null
real 0m4.862s
user 0m6.619s
sys 0m0.982s
Diffstat (limited to 'src/chunklist_test.go')
| -rw-r--r-- | src/chunklist_test.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/chunklist_test.go b/src/chunklist_test.go index 2f8ef7e5..faaf04fe 100644 --- a/src/chunklist_test.go +++ b/src/chunklist_test.go @@ -6,7 +6,7 @@ import ( ) func TestChunkList(t *testing.T) { - cl := NewChunkList(func(s *string, i int) *Item { + cl := NewChunkList(func(s []rune, i int) *Item { return &Item{text: s, rank: Rank{0, 0, uint32(i * 2)}} }) @@ -17,8 +17,8 @@ func TestChunkList(t *testing.T) { } // Add some data - cl.Push("hello") - cl.Push("world") + cl.Push([]rune("hello")) + cl.Push([]rune("world")) // Previously created snapshot should remain the same if len(snapshot) > 0 { @@ -36,8 +36,8 @@ func TestChunkList(t *testing.T) { if len(*chunk1) != 2 { t.Error("Snapshot should contain only two items") } - if *(*chunk1)[0].text != "hello" || (*chunk1)[0].rank.index != 0 || - *(*chunk1)[1].text != "world" || (*chunk1)[1].rank.index != 2 { + if string((*chunk1)[0].text) != "hello" || (*chunk1)[0].rank.index != 0 || + string((*chunk1)[1].text) != "world" || (*chunk1)[1].rank.index != 2 { t.Error("Invalid data") } if chunk1.IsFull() { @@ -46,7 +46,7 @@ func TestChunkList(t *testing.T) { // Add more data for i := 0; i < chunkSize*2; i++ { - cl.Push(fmt.Sprintf("item %d", i)) + cl.Push([]rune(fmt.Sprintf("item %d", i))) } // Previous snapshot should remain the same @@ -64,8 +64,8 @@ func TestChunkList(t *testing.T) { t.Error("Unexpected number of items") } - cl.Push("hello") - cl.Push("world") + cl.Push([]rune("hello")) + cl.Push([]rune("world")) lastChunkCount := len(*snapshot[len(snapshot)-1]) if lastChunkCount != 2 { |
