base62-rb 0.2.0 → 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 +6 -1
- data/benchmarks/comparison.rb +42 -0
- data/lib/base62-rb.rb +1 -1
- data/lib/base62/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41ababc33c9761ec527aa12e739ee3a3335fae10
|
4
|
+
data.tar.gz: 7e9d24d5da22aef6f43a02aad978d9654eb2728d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 096fc1a781be8088931c95b83f33d42c415535f10f3de2a9331461831ba709a2e330afa81100f2025cd512b8f612782aed1d7ad904e9e53586d9c6b3928161c9
|
7
|
+
data.tar.gz: f495b8ef1151b4e842b8af79cfd237a4120c9b73180c083c78078f3c03c80d99668f37da33e067dc47becfa15675488d544ed6b814a2fc373c1b00c19fd08a73
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Base62 in Ruby
|
2
2
|
|
3
|
-
A simple and fast implementation of base62 in Ruby without too much sugar and magic.
|
3
|
+
A simple and fast implementation of base62 in pure Ruby without too much sugar and magic.
|
4
4
|
|
5
5
|
It uses character set: `0-9`, `a-z`, `A-Z` for encoding and decoding.
|
6
6
|
|
@@ -34,6 +34,11 @@ Base62.decode("hjNv8tS3K")
|
|
34
34
|
# => 3781504209452600
|
35
35
|
```
|
36
36
|
|
37
|
+
## Benchmark
|
38
|
+
|
39
|
+
See the comparison [here](benchmarks/comparison.rb)
|
40
|
+
|
41
|
+
|
37
42
|
## License
|
38
43
|
|
39
44
|
MIT License - Copyright (c) 2014 Steven Yue
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require "benchmark"
|
2
|
+
|
3
|
+
# Results tested on Macbook Air 1.4 GHz Intel Core i5, 8 GB 1600 MHz DDR3
|
4
|
+
# Using Ruby 2.1.3p242
|
5
|
+
|
6
|
+
# gem base62-rb v0.3.0
|
7
|
+
require_relative '../lib/base62-rb.rb'
|
8
|
+
|
9
|
+
time = Benchmark.measure do
|
10
|
+
1_000_000.times do |i|
|
11
|
+
encode = Base62.encode(i)
|
12
|
+
decode = Base62.decode(encode)
|
13
|
+
raise "Assertion error!" unless i == decode
|
14
|
+
end
|
15
|
+
end
|
16
|
+
puts time # => 3.280000 0.010000 3.290000 ( 3.311349))
|
17
|
+
|
18
|
+
|
19
|
+
# gem radix62 v1.0.1
|
20
|
+
# https://github.com/matiaskorhonen/radix62
|
21
|
+
require 'radix62'
|
22
|
+
time = Benchmark.measure do
|
23
|
+
1_000_000.times do |i|
|
24
|
+
encode = i.encode62
|
25
|
+
decode = encode.decode62
|
26
|
+
raise "Assertion error!" unless i == decode
|
27
|
+
end
|
28
|
+
end
|
29
|
+
puts time # => 6.790000 0.020000 6.810000 ( 6.842925)
|
30
|
+
|
31
|
+
|
32
|
+
# gem base62 v1.0.0
|
33
|
+
# https://github.com/jtzemp/base62
|
34
|
+
require 'base62'
|
35
|
+
time = Benchmark.measure do
|
36
|
+
1_000_000.times do |i|
|
37
|
+
encode = i.base62_encode
|
38
|
+
decode = encode.base62_decode
|
39
|
+
raise "Assertion error!" unless i == decode
|
40
|
+
end
|
41
|
+
end
|
42
|
+
puts time # => 10.370000 0.030000 10.400000 ( 10.452976)
|
data/lib/base62-rb.rb
CHANGED
data/lib/base62/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: base62-rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Yue
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
53
|
- base62-rb.gemspec
|
54
|
+
- benchmarks/comparison.rb
|
54
55
|
- lib/base62-rb.rb
|
55
56
|
- lib/base62/version.rb
|
56
57
|
- test/base62_test.rb
|