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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 729b23f1bf5f70dc6aa94e03c7188d83dd197b57
4
- data.tar.gz: a9d5c5b971eed05ce46ab22fa24bcd162ed993b2
3
+ metadata.gz: 41ababc33c9761ec527aa12e739ee3a3335fae10
4
+ data.tar.gz: 7e9d24d5da22aef6f43a02aad978d9654eb2728d
5
5
  SHA512:
6
- metadata.gz: f40f4e4f512c0ef983583350c87d468bb5bd325df6dc88ac447ca862bd94e52ec4b24ea520af0f641894c79136a65c30a0c1a30fd40ac96f86c8759aa8e55494
7
- data.tar.gz: 8fed19731093b78e6c9ab87b9f967ec00ee0abfb2cbd1b8ab0e8d3dcd035daff7c4c79f0910935cd26350764764709f09c06dc9fceb95d229655ef670dac2039
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)
@@ -14,7 +14,7 @@ module Base62
14
14
  while num > 0
15
15
  # prepend base62 charaters
16
16
  str = KEYS[num % BASE] + str
17
- num /= BASE
17
+ num = num / BASE
18
18
  end
19
19
  return str
20
20
  end
@@ -1,3 +1,3 @@
1
1
  module Base62
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
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.2.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