benchparser 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +50 -0
- data/lib/benchparser/parsers/go.rb +44 -0
- data/lib/benchparser/parsers/ruby.rb +8 -0
- data/lib/benchparser/parsers/ts.rb +8 -0
- data/lib/benchparser/result.rb +11 -0
- data/lib/benchparser/version.rb +3 -0
- data/lib/benchparser.rb +20 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 552a3e1a134a557ecda76faf8080d2518e3f8222
|
4
|
+
data.tar.gz: 33eb890e1a69cb8ef8a57dae2b91a3bdd770977a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dddd7e03efe650d96cec71a5fabcf23a5cdecf7743a3a3776a49b9df6b2f6972e2478ad8d75196e259f06cdc672bfa182e0156a91d7e0e7d5ba6a15ccf86f4f0
|
7
|
+
data.tar.gz: cbf57d8f9a661ce358ffdf39c517869f15734e921a098f5aeb2bebadd93361da8b07ba2eadff92f3bc71b40d0e972f533cae248c1c73edd7d973c03a91afe9f4
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
[![Build Status](https://travis-ci.com/drish/benchparser.svg?branch=master)](https://travis-ci.com/drish/benchparser)
|
2
|
+
|
3
|
+
# Benchparser
|
4
|
+
|
5
|
+
Benchparser is a parser for multiple benchmark output formats
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'benchparser'
|
11
|
+
```
|
12
|
+
|
13
|
+
|
14
|
+
### Usage
|
15
|
+
|
16
|
+
Golang benchmark standard output
|
17
|
+
|
18
|
+
```text
|
19
|
+
goos: darwin
|
20
|
+
goarch: amd64
|
21
|
+
pkg: github.com/drish/parser
|
22
|
+
BenchmarkFib1-8 1000000000 2.48 ns/op 0 B/op 0 allocs/op
|
23
|
+
PASS
|
24
|
+
ok github.com/drish/parser 9.960s
|
25
|
+
"
|
26
|
+
```
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require 'benchparser'
|
30
|
+
|
31
|
+
parsed = Bp.parse(data)
|
32
|
+
parsed.language # go
|
33
|
+
parsed.goos # darwin
|
34
|
+
parsed.pkg # darwin
|
35
|
+
parsed.functions.count # 1
|
36
|
+
parsed.functions.first[:iterations] # 1000000000
|
37
|
+
parsed.functions.first[:ns_op] # 2.48
|
38
|
+
parsed.functions.first[:bytes_op] # 0
|
39
|
+
parsed.functions.first[:allocs_op] # 0
|
40
|
+
```
|
41
|
+
|
42
|
+
|
43
|
+
#### TODO
|
44
|
+
|
45
|
+
- [ ] Ruby [benchmark](https://ruby-doc.org/stdlib-2.5.0/libdoc/benchmark/rdoc/)
|
46
|
+
- [ ] Python [timeit](https://docs.python.org/2/library/timeit.html)
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/drish/benchparser.
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Benchparser
|
2
|
+
module Parsers
|
3
|
+
class Go < Benchparser::Result
|
4
|
+
attr_accessor :goos, :goarch, :pkg
|
5
|
+
|
6
|
+
def initialize(raw_data)
|
7
|
+
super(language: 'go')
|
8
|
+
lines = raw_data.split("\n")
|
9
|
+
lines.each_with_index do |line, index|
|
10
|
+
case index
|
11
|
+
when 0
|
12
|
+
@goos = line.sub('goos: ', '') if line.include?('goos')
|
13
|
+
when 1
|
14
|
+
@goarch = line.sub('goarch: ', '') if line.include?('goarch')
|
15
|
+
when 2
|
16
|
+
@pkg = line.sub('pkg: ', '') if line.include?('pkg')
|
17
|
+
else
|
18
|
+
parsed_line = parse_function(line)
|
19
|
+
@functions << parsed_line unless parsed_line.nil?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def parse_function(line)
|
25
|
+
fn = line.split(' ')
|
26
|
+
return if fn.include?('PASS') or fn.include?('ok')
|
27
|
+
{
|
28
|
+
name: fn.first,
|
29
|
+
iterations: fn[1],
|
30
|
+
ns_op: fn[2],
|
31
|
+
bytes_op: fn[4],
|
32
|
+
allocs_op: fn[6]
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
class << self
|
37
|
+
def parse(raw_data)
|
38
|
+
raise Bp::ParserError.new if raw_data.nil?
|
39
|
+
Bp::Parsers::Go.new(raw_data)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/benchparser.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# version
|
2
|
+
require "benchparser/version"
|
3
|
+
|
4
|
+
# modules
|
5
|
+
require "benchparser/result"
|
6
|
+
require "benchparser/parsers/go"
|
7
|
+
require "benchparser/parsers/ruby"
|
8
|
+
require "benchparser/parsers/ts"
|
9
|
+
|
10
|
+
module Benchparser
|
11
|
+
class ParseError < StandardError; end
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def parse
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# shortcut
|
20
|
+
Bp = Benchparser
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: benchparser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Derich Pacheco
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-09-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry-byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email: carlosderich@gmail.com
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- README.md
|
76
|
+
- lib/benchparser.rb
|
77
|
+
- lib/benchparser/parsers/go.rb
|
78
|
+
- lib/benchparser/parsers/ruby.rb
|
79
|
+
- lib/benchparser/parsers/ts.rb
|
80
|
+
- lib/benchparser/result.rb
|
81
|
+
- lib/benchparser/version.rb
|
82
|
+
homepage: https://github.com/drish/benchparser
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata: {}
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options: []
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '2.3'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.6.14
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: Benchparser - benchmark output parser
|
106
|
+
test_files: []
|