in_array 0.1.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -17
- data/in_array.gemspec +1 -1
- data/lib/in_array/version.rb +1 -1
- data/rakefile.rb +2 -11
- data/reek.txt +1 -1
- metadata +5 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95907753a04429de9964d7f27920a53dfc6191ee
|
4
|
+
data.tar.gz: 7d38abadf2bb61d4d18f40dc810837a4aff9caff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3fc623ca70ec10b9c3ed6e6a34a085083cc7bb9f0c74eba9d0477ae4d646cb5004e9f8ec8bc0bf96d127b7bf089c97a1527ecd7ed6e275afed5c5ecf48b5933
|
7
|
+
data.tar.gz: 515d17c19f188634a3879d9c5ad8d98731cd511965eae928612fd340d5f0f998d4ddf954adbaa022d34abcab72dae19da94d8cba2dce000ee68afb6c31b14bdc
|
data/README.md
CHANGED
@@ -82,49 +82,50 @@ penalty. The benchmark tests that follow show that the in_array gem should be
|
|
82
82
|
expected to improve performance when compared with the simulated polymorphism
|
83
83
|
alternative.
|
84
84
|
|
85
|
+
All benchmarks were done with:
|
86
|
+
ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]
|
87
|
+
|
85
88
|
The first test assumes a simple scenario with only the Array class. Polymorphism
|
86
89
|
is simulated using the is_a? method:
|
87
90
|
|
88
|
-
C:\Sites\in_array>ruby bench\simple_bench.rb
|
89
91
|
Warming up --------------------------------------
|
90
92
|
Process with in_array
|
91
|
-
5.
|
93
|
+
5.332k i/100ms
|
92
94
|
Process with is_a?
|
93
|
-
4.
|
95
|
+
4.084k i/100ms
|
94
96
|
Calculating -------------------------------------
|
95
97
|
Process with in_array
|
96
|
-
|
98
|
+
60.573k (± 0.2%) i/s - 303.924k in 5.017537s
|
97
99
|
Process with is_a?
|
98
|
-
|
100
|
+
45.736k (± 0.2%) i/s - 228.704k in 5.000545s
|
99
101
|
|
100
102
|
Comparison:
|
101
|
-
Process with in_array:
|
102
|
-
Process with is_a? :
|
103
|
+
Process with in_array: 60572.6 i/s
|
104
|
+
Process with is_a? : 45736.0 i/s - 1.32x slower
|
103
105
|
|
104
106
|
The second scenario adds a user defined array like class. In this case, two
|
105
107
|
methods of simulated polymorphism are tested, based on include? and a hash
|
106
108
|
of allowed array classes. Here are those results.
|
107
109
|
|
108
|
-
C:\Sites\in_array>ruby bench\complex_bench.rb
|
109
110
|
Warming up --------------------------------------
|
110
111
|
Process with in_array
|
111
|
-
5.
|
112
|
+
5.334k i/100ms
|
112
113
|
Process with hash[]
|
113
|
-
1.
|
114
|
+
1.565k i/100ms
|
114
115
|
Process with include?
|
115
|
-
|
116
|
+
2.656k i/100ms
|
116
117
|
Calculating -------------------------------------
|
117
118
|
Process with in_array
|
118
|
-
|
119
|
+
60.959k (± 0.3%) i/s - 309.372k in 5.075113s
|
119
120
|
Process with hash[]
|
120
|
-
|
121
|
+
16.323k (± 0.7%) i/s - 82.945k in 5.081691s
|
121
122
|
Process with include?
|
122
|
-
|
123
|
+
28.529k (± 0.2%) i/s - 143.424k in 5.027394s
|
123
124
|
|
124
125
|
Comparison:
|
125
|
-
Process with in_array:
|
126
|
-
Process with include?:
|
127
|
-
Process with hash[] :
|
126
|
+
Process with in_array: 60959.3 i/s
|
127
|
+
Process with include?: 28528.6 i/s - 2.14x slower
|
128
|
+
Process with hash[] : 16323.1 i/s - 3.73x slower
|
128
129
|
|
129
130
|
## Contributing
|
130
131
|
|
data/in_array.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_development_dependency 'rake'
|
22
22
|
s.add_development_dependency 'minitest', "~> 5.7"
|
23
23
|
s.add_development_dependency 'minitest_visible', "~> 0.1"
|
24
|
-
s.add_development_dependency 'reek', "~>
|
24
|
+
s.add_development_dependency 'reek', "~> 5.0.2"
|
25
25
|
s.add_development_dependency 'rdoc', "~> 5.0"
|
26
26
|
|
27
27
|
s.files = `git ls-files`.split($/)
|
data/lib/in_array/version.rb
CHANGED
data/rakefile.rb
CHANGED
@@ -2,26 +2,17 @@
|
|
2
2
|
# coding: utf-8
|
3
3
|
|
4
4
|
require 'rake/testtask'
|
5
|
-
require 'rdoc/task'
|
6
5
|
require "bundler/gem_tasks"
|
7
6
|
|
8
|
-
RDoc::Task.new do |rdoc|
|
9
|
-
rdoc.rdoc_dir = "rdoc"
|
10
|
-
|
11
|
-
#List out all the files to be documented.
|
12
|
-
rdoc.rdoc_files.include("lib/**/*.rb", "license.txt", "readme.md")
|
13
|
-
|
14
|
-
rdoc.options << '--visibility' << 'private'
|
15
|
-
end
|
16
|
-
|
17
7
|
Rake::TestTask.new do |t|
|
18
8
|
t.test_files = ['tests/in_array_test.rb']
|
19
9
|
t.verbose = false
|
10
|
+
t.warning = true
|
20
11
|
end
|
21
12
|
|
22
13
|
desc "Run a scan for smelly code!"
|
23
14
|
task :reek do |t|
|
24
|
-
`reek lib
|
15
|
+
`reek --no-color lib > reek.txt`
|
25
16
|
end
|
26
17
|
|
27
18
|
desc "Fire up an IRB session with in_array preloaded."
|
data/reek.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
0 total warnings
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: in_array
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Camilleri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 5.0.2
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 5.0.2
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rdoc
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,10 +135,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.2
|
138
|
+
rubygems_version: 2.5.2
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Encapsulate data in an array.
|
142
142
|
test_files:
|
143
143
|
- tests/in_array_test.rb
|
144
|
-
has_rdoc: true
|