hyper_iterator 0.2.2 → 0.3.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 +3 -0
- data/benchmark/memory_bm/each_slice.rb +4 -4
- data/benchmark/memory_bm/each_slice_bang.rb +4 -4
- data/bin/bm +2 -2
- data/lib/hyper_iterator/version.rb +1 -1
- data/lib/hyper_iterator.rb +4 -0
- data/lib/iterators/each_bang.rb +2 -2
- data/lib/iterators/each_slice_bang.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55ad0f990d6b8995564bb008dfab3d7b31466571
|
4
|
+
data.tar.gz: a1d40fae14f08758adc32ed5feb422d3e057ce61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21983520dc57eff8a897387e2ec5d10f4d3c717c3ecf32b747050f5bf28a56eda9c5479c7bbd6723a6205b961f4f93d0e018f4edeed31337f08a70827072300e
|
7
|
+
data.tar.gz: c8a76fb37c41b0ba6738f6c94d9bfc4df68ee48379f28cca2caddbe3a67e742711e34a5060ed47acc989b87e4123e5d793d98c319dd801ad606863103431bdad
|
data/README.md
CHANGED
@@ -35,6 +35,9 @@ Or install it yourself as:
|
|
35
35
|
|
36
36
|
- `each_slice!`
|
37
37
|
- `each!`
|
38
|
+
- `HyperIterator.each!`: This is the same as `each!`. But it takes an array as argument.
|
39
|
+
This is added because there are gems that implement their own `each` method (e.g. the pg
|
40
|
+
gem). Instead of monkey patching all the gems out there, this is a compromise for flexibility.
|
38
41
|
|
39
42
|
## Gotcha
|
40
43
|
|
@@ -2,12 +2,12 @@ require 'benchmark'
|
|
2
2
|
require_relative '../../lib/hyper_iterator'
|
3
3
|
$stdout.sync = true
|
4
4
|
|
5
|
-
puts
|
6
|
-
puts '
|
5
|
+
puts
|
6
|
+
puts '--------------- Array#each_slice --------------'
|
7
|
+
puts '#i user system total real'
|
8
|
+
|
7
9
|
base_arr = Array.new(10000) { '-' * 10 }
|
8
10
|
arrs = [base_arr]
|
9
|
-
puts 'finished creating base array'
|
10
|
-
puts 'each iteration begins'
|
11
11
|
|
12
12
|
i = 0
|
13
13
|
while true
|
@@ -2,12 +2,12 @@ require 'benchmark'
|
|
2
2
|
require_relative '../../lib/hyper_iterator'
|
3
3
|
$stdout.sync = true
|
4
4
|
|
5
|
-
puts
|
6
|
-
puts '
|
5
|
+
puts
|
6
|
+
puts '-------------- Array#each_slice! --------------'
|
7
|
+
puts '#i user system total real'
|
8
|
+
|
7
9
|
base_arr = Array.new(10000) { '-' * 10 }
|
8
10
|
arrs = [base_arr]
|
9
|
-
puts 'finished creating base array'
|
10
|
-
puts 'each iteration begins'
|
11
11
|
|
12
12
|
i = 0
|
13
13
|
while true
|
data/bin/bm
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
|
3
3
|
docker_command="docker run -m=4m -v `pwd`:`pwd` -w `pwd` hyper_iterator ruby ./benchmark/memory_bm"
|
4
|
-
if [ "$1" = "each" ] || [ "$1" = 1 ]; then
|
4
|
+
if [ "$1" = "each!" ] || [ "$1" = 1 ]; then
|
5
5
|
eval "$docker_command/each.rb"
|
6
6
|
eval "$docker_command/each_bang.rb"
|
7
|
-
elif [ "$1" = "
|
7
|
+
elif [ "$1" = "each_slice!" ] || [ "$1" = 2 ]; then
|
8
8
|
eval "$docker_command/each_slice.rb"
|
9
9
|
eval "$docker_command/each_slice_bang.rb"
|
10
10
|
else
|
data/lib/hyper_iterator.rb
CHANGED
data/lib/iterators/each_bang.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module HyperIterator
|
2
|
-
def each_slice!(slice_size
|
2
|
+
def each_slice!(slice_size)
|
3
3
|
i = 0
|
4
4
|
|
5
5
|
while count > 0
|
@@ -8,7 +8,7 @@ module HyperIterator
|
|
8
8
|
current_slice << shift
|
9
9
|
i += 1
|
10
10
|
end
|
11
|
-
|
11
|
+
yield current_slice
|
12
12
|
i = 0
|
13
13
|
end
|
14
14
|
nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyper_iterator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edmund Li
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|