niceql 0.1.23 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -3
- data/CHANGELOG.md +4 -0
- data/lib/benchmark/cat.rb +20 -66
- data/lib/benchmark/gsub.rb +23 -14
- data/lib/benchmark/txt +748 -748
- data/lib/niceql/version.rb +1 -1
- data/niceql.gemspec +3 -2
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec80b35674703f65be9841e1596065cb395f71d31eca1704e40648390de88b6c
|
4
|
+
data.tar.gz: b59ca0d932ef22245dc040425260a050441ac69789cb97284983f07e71088bf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c87708d4886737e56558278e958563292cc0dbb955d204ed38ff0c6e8f9f8797bebf1ef67caf531e13f80e70b7f9f762e147f19f762aa8e1f7b9e8cd5c80912f
|
7
|
+
data.tar.gz: 98fc43d968e68143940722d341f828316313b3f614785024a0203ea5e294df4c1c3b3ff4494d207353690ec43b27c64680eee7b71789286257a21bddd4fc44b0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/benchmark/cat.rb
CHANGED
@@ -1,80 +1,34 @@
|
|
1
1
|
require 'benchmark/ips'
|
2
2
|
|
3
|
-
$str = File.open( './txt' ).readlines.join(' ')
|
4
|
-
|
5
|
-
def str_gen( size, rand_size )
|
6
|
-
$str[ rand(50000), size + rand(rand_size) ]
|
7
|
-
end
|
8
|
-
|
9
|
-
def chunk_gen( size )
|
10
|
-
$str[ rand(50000), size ]
|
11
|
-
end
|
12
|
-
|
13
3
|
# 2 + 1 = 3 object
|
14
|
-
def slow_plus
|
15
|
-
|
4
|
+
def slow_plus
|
5
|
+
'foo' + 'bar'
|
16
6
|
end
|
17
7
|
|
18
8
|
# 2 + 1 = 3 object
|
19
|
-
def slow_concat
|
20
|
-
|
9
|
+
def slow_concat
|
10
|
+
'foo'.concat 'bar'
|
21
11
|
end
|
22
12
|
|
23
13
|
# 2 + 1 = 3 object
|
24
|
-
def slow_append
|
25
|
-
|
14
|
+
def slow_append
|
15
|
+
'foo' << 'bar'
|
26
16
|
end
|
27
17
|
|
28
|
-
|
29
|
-
|
18
|
+
# 1 object
|
19
|
+
def fast
|
20
|
+
'foo' 'bar'
|
30
21
|
end
|
31
22
|
|
32
|
-
|
33
|
-
|
34
|
-
def test_concat(size, rand_size, chunk_size = 1)
|
35
|
-
Benchmark.ips do |x|
|
36
|
-
x.report('String#+') { slow_plus(size, rand_size) }
|
37
|
-
x.report('String#concat') { slow_concat(size, rand_size) }
|
38
|
-
x.report('String#append') { slow_append(size, rand_size) }
|
39
|
-
x.report('"#{\'foo\'}#{\'bar\'}"') { fast_interpolation(size, rand_size) }
|
40
|
-
x.compare!
|
41
|
-
end
|
42
|
-
|
43
|
-
# Benchmark.ips do |x|
|
44
|
-
# puts '------------------------------+ chunk----------------'
|
45
|
-
# x.report('String#+') { str_gen(size, rand_size ) + chunk_gen(chunk_size) }
|
46
|
-
# x.report('String#concat') { str_gen(size, rand_size ).concat chunk_gen(chunk_size) }
|
47
|
-
# x.report('String#append') { str_gen(size, rand_size ) << chunk_gen(chunk_size) }
|
48
|
-
# x.report('"#{\'foo\'}#{\'bar\'}"') { "#{str_gen(size, rand_size )}#{chunk_gen(chunk_size)}" }
|
49
|
-
# x.compare!
|
50
|
-
# end
|
51
|
-
#
|
52
|
-
# Benchmark.ips do |x|
|
53
|
-
# puts '------------------------------chunk +----------------'
|
54
|
-
# x.report('String#+') { str_gen(size, rand_size ) + chunk_gen(chunk_size) }
|
55
|
-
# x.report('String#concat') { str_gen(size, rand_size ).concat chunk_gen(chunk_size) }
|
56
|
-
# x.report('String#append') { str_gen(size, rand_size ) << chunk_gen(chunk_size) }
|
57
|
-
# x.report('"#{\'foo\'}#{\'bar\'}"') { "#{str_gen(size, rand_size )}#{chunk_gen(chunk_size)}" }
|
58
|
-
# x.compare!
|
59
|
-
# end
|
60
|
-
|
61
|
-
|
62
|
-
Benchmark.ips do |x|
|
63
|
-
puts '------------------------------triple spaced----------------'
|
64
|
-
x.report('String#+') { str_gen(size, rand_size ) + ' '+ str_gen(size, rand_size) }
|
65
|
-
x.report('String#concat') { str_gen(size, rand_size ).concat(' ').concat( str_gen(size, rand_size ) )}
|
66
|
-
x.report('String#append') { str_gen(size, rand_size ) << ' ' << str_gen(size, rand_size ) }
|
67
|
-
x.report('"#{\'foo\'}#{\'bar\'}"') { "#{str_gen(size, rand_size )} #{chunk_gen(chunk_size)}" }
|
68
|
-
x.compare!
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
Benchmark.ips do |x|
|
73
|
-
puts '------------------------------triple spaced----------------'
|
74
|
-
x.report('String#+') { str_gen(size, rand_size ) + str_gen(size, rand_size ) + str_gen(size, rand_size) }
|
75
|
-
x.report('String#concat') { str_gen(size, rand_size ).concat(str_gen(size, rand_size )).concat( str_gen(size, rand_size ) )}
|
76
|
-
x.report('String#append') { str_gen(size, rand_size ) << str_gen(size, rand_size ) << str_gen(size, rand_size ) }
|
77
|
-
x.report('"#{\'foo\'}#{\'bar\'}"') { "#{str_gen(size, rand_size )}#{str_gen(size, rand_size )}#{chunk_gen(chunk_size)}" }
|
78
|
-
x.compare!
|
79
|
-
end
|
23
|
+
def fast_interpolation
|
24
|
+
"#{'foo'}#{'bar'}"
|
80
25
|
end
|
26
|
+
|
27
|
+
Benchmark.ips do |x|
|
28
|
+
x.report('String#+') { slow_plus }
|
29
|
+
x.report('String#concat') { slow_concat }
|
30
|
+
x.report('String#append') { slow_append }
|
31
|
+
x.report('"foo" "bar"') { fast }
|
32
|
+
x.report('"#{\'foo\'}#{\'bar\'}"') { fast_interpolation }
|
33
|
+
x.compare!
|
34
|
+
end
|
data/lib/benchmark/gsub.rb
CHANGED
@@ -1,25 +1,34 @@
|
|
1
1
|
require 'benchmark/ips'
|
2
2
|
|
3
|
-
$str = File.open( './txt' ).readlines.join(' ')
|
4
|
-
|
5
3
|
# 2 + 1 = 3 object
|
6
|
-
def
|
7
|
-
|
4
|
+
def slow_plus
|
5
|
+
'foo' + 'bar'
|
8
6
|
end
|
9
7
|
|
10
8
|
# 2 + 1 = 3 object
|
11
|
-
def
|
12
|
-
|
9
|
+
def slow_concat
|
10
|
+
'foo'.concat 'bar'
|
13
11
|
end
|
14
12
|
|
13
|
+
# 2 + 1 = 3 object
|
14
|
+
def slow_append
|
15
|
+
'foo' << 'bar'
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
# 1 object
|
19
|
+
def fast
|
20
|
+
'foo' 'bar'
|
21
|
+
end
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
x.compare!
|
24
|
-
end
|
23
|
+
def fast_interpolation
|
24
|
+
"#{'foo'}#{'bar'}"
|
25
25
|
end
|
26
|
+
|
27
|
+
Benchmark.ips do |x|
|
28
|
+
x.report('String#+') { slow_plus }
|
29
|
+
x.report('String#concat') { slow_concat }
|
30
|
+
x.report('String#append') { slow_append }
|
31
|
+
x.report('"foo" "bar"') { fast }
|
32
|
+
x.report('"#{\'foo\'}#{\'bar\'}"') { fast_interpolation }
|
33
|
+
x.compare!
|
34
|
+
end
|