Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance #4

Merged
merged 8 commits into from
Sep 14, 2016
Merged

Improve performance #4

merged 8 commits into from
Sep 14, 2016

Conversation

haya14busa
Copy link
Member

No description provided.

benchmark                            old ns/op     new ns/op     delta
BenchmarkVimLParser_VimLParser-4     522557385     384606362     -26.40%
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 81.585% when pulling ce9df41 on performance into 91d84c9 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 81.585% when pulling ce9df41 on performance into 91d84c9 on master.

before:

         .          .    140:func viml_split(s string, sep string) []string {
         .          .    141:   if sep == `\zs` {
         .          .    142:           var ss []string
         .          .    143:           for _, r := range s {
   58.05MB    58.05MB    144:                   ss = append(ss, string(r))
         .          .    145:           }
         .          .    146:           return ss
         .          .    147:   }
         .          .    148:   panic("NotImplemented viml_split")
         .          .    149:}

after:

         .          .    140:func viml_split(s string, sep string) []string {
         .          .    141:   if sep == `\zs` {
   21.02MB    21.02MB    142:           ss := make([]string, 0, len(s))
         .          .    143:           for _, r := range s {
       4MB        4MB    144:                   ss = append(ss, string(r))
         .          .    145:           }
         .          .    146:           return ss
         .          .    147:   }
         .          .    148:   panic("NotImplemented viml_split")
         .          .    149:}
…erface{}{lnum, col}

benchmark                            old ns/op     new ns/op     delta
BenchmarkVimLParser_VimLParser-4     366894571     295205749     -19.54%
benchmark                            old ns/op     new ns/op     delta
BenchmarkVimLParser_VimLParser-4     295205749     262219875     -11.17%
benchmark                            old ns/op     new ns/op     delta
BenchmarkVimLParser_VimLParser-4     262219875     248887206     -5.08%
benchmark                            old ns/op     new ns/op     delta
BenchmarkVimLParser_VimLParser-4     248887206     235228838     -5.49%
@haya14busa
Copy link
Member Author

# benchcmp mem.0 mem.8                                                                                                                                                    (git)-[performance]
benchmark                            old ns/op     new ns/op     delta
BenchmarkVimLParser_VimLParser-4     522557385     239071919     -54.25%

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 81.626% when pulling 71f910d on performance into 91d84c9 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 81.626% when pulling 71f910d on performance into 91d84c9 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 81.626% when pulling 1dc4167 on performance into 91d84c9 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 81.626% when pulling 1dc4167 on performance into 91d84c9 on master.

@haya14busa
Copy link
Member Author

Benchmarks

$ pwd
/home/haya14busa/src/github.com/ynkdir/vim-vimlparser

$ git rev-parse HEAD
2fff43c58968a18bc01bc8304df68bde01af04d9

$ wc -l < autoload/vimlparser.vim
5195

$ time vim -u NONE -N --cmd "let &rtp .= ',' . getcwd()" --cmd "silent call vimlparser#test('autoload/vimlparser.vim')" -c ":q"
vim -u NONE -N --cmd "let &rtp .= ',' . getcwd()" --cmd  -c ":q"  48.88s user 0.05s system 99% cpu 48.942 total

$ python3 -V
Python 3.5.0

$ time python3 py/vimlparser.py autoload/vimlparser.vim > /dev/null
python3 py/vimlparser.py autoload/vimlparser.vim > /dev/null  4.17s user 0.04s system 99% cpu 4.236 total

$ pypy3 -V
Python 3.2.5 (b2091e973da69152b3f928bfaabd5d2347e6df46, Mar 04 2016, 07:08:30)
[PyPy 2.4.0 with GCC 5.3.0]

$ time pypy3 py/vimlparser.py autoload/vimlparser.vim > /dev/null
pypy3 py/vimlparser.py autoload/vimlparser.vim > /dev/null  2.63s user 0.06s system 99% cpu 2.694 total

$ node --version
v4.2.3

$ time node js/vimlparser.js autoload/vimlparser.vim > /dev/null
node js/vimlparser.js autoload/vimlparser.vim > /dev/null  0.77s user 0.04s system 125% cpu 0.644 total

$ go get github.com/haya14busa/go-vimlparser/cmd/vimlparser
$ time vimlparser autoload/vimlparser.vim > /dev/null
vimlparser autoload/vimlparser.vim > /dev/null  0.36s user 0.02s system 125% cpu 0.299 total
Language Time (sec)
Vim script 48.88s
Python3 (3.5.0) 4.17s
pypy3 2.63s
node 0.77s
go 0.36s

Something Extra

$ pwd
/home/haya14busa/src/github.com/haya14busa/go-vimlparser

$ git rev-parse HEAD
db7e1558c2c9a2a85b8b61bbfd2550f348b5677e

$ time go run cmd/vimlparser/main.go ../../ynkdir/vim-vimlparser/autoload/vimlparser.vim > /dev/null
go run cmd/vimlparser/main.go  > /dev/null  0.54s user 0.08s system 124% cpu 0.491 total

Go is the fastest even with compile time.

@haya14busa haya14busa merged commit 33fd88f into master Sep 14, 2016
@haya14busa haya14busa deleted the performance branch September 14, 2016 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants