README.md in ryodo-0.2.4.1 vs README.md in ryodo-0.2.5
- old
+ new
@@ -1,7 +1,9 @@
-# ryodo [![](https://secure.travis-ci.org/asaaki/ryodo.png)](http://travis-ci.org/asaaki/ryodo)
+# ryodo
+[![gem version](https://badge.fury.io/rb/ryodo.png)](http://badge.fury.io/rb/ryodo) [![build status](https://secure.travis-ci.org/asaaki/ryodo.png)](http://travis-ci.org/asaaki/ryodo) [![dev dependency status](https://gemnasium.com/asaaki/ryodo.png)](https://gemnasium.com/asaaki/ryodo) [![code climate](https://codeclimate.com/github/asaaki/ryodo.png)](https://codeclimate.com/github/asaaki/ryodo) [![coverage status](https://coveralls.io/repos/asaaki/ryodo/badge.png?branch=master)](https://coveralls.io/r/asaaki/ryodo?branch=master)
+
**ryōdo【領土】 りょうど — A domain name parser using public suffix list**
Do you ever wanted to know if `suspicious.domain.name.blerp` is really a valid domain?
Do you ever wanted to know what is the domain portion of `others.guy.awesome.domain.co.jp`?
@@ -9,11 +11,13 @@
Then you should try `ryodo` and get the answers!
Notice: This gem **does not** check DNS records to verify if a name was taken and registered, this is not its purpose.
I am a big fan of the UNIX philosophy: *»Write programs that do one thing and do it well.«*
+My blog post about `ryodo`: [ryodo - domain parser (2012-06-02)](http://codecraft.io/2012/06/02/ryodo-domain-parser/)
+
## Usage
```ruby
dom = Ryodo.parse("my.awesome.domain.co.jp")
#=> Ryodo::Domain
@@ -135,11 +139,11 @@
## Benchmark
-There is another gem called [public_suffix](https://github.com/weppos/public_suffix_service), which does nearly the same (maybe with more features I don't need).
+There is another gem called [public_suffix](https://github.com/weppos/publicsuffix-ruby), which does nearly the same (maybe with more features I don't need).
So I did a tiny benchmark.
**Setup**
@@ -147,70 +151,80 @@
Some of them are also invalid (to test, if you implementation works correctly).
I added some very long domain names with many parts (for look-up time scale).
-Finally 72 entries to check.
-
-Ruby: 1.9.3-p194, no special patches
-
We only do a basic parsing and retrieve the registered/registrable domain. (Should hit the most important code of the gems.)
-**Test script snippet**
+The benchmark script can be found at [checks/benchmark.rb (branch: prof)](./blob/prof/checks/benchmark.rb).
-```ruby
-# DOMAINS is the array of domain entries - shuffled on every benchmark run
+**Notes**
-LOOPS = 1_000
+`PublicSuffix.parse(…)` will raise errors if domain input is invalid (e.g. not a registrable domain).
-Benchmark.bmbm do |b|
+`Ryodo.parse(…)` won't raise but return nil values for invalid stuff (it only raises if input is not a String, of course).
- b.report "ryodo" do
- LOOPS.times do
- DOMAINS.each do |domain|
- Ryodo.parse(domain).domain # returns nil if not valid
- end
- end
- end
+**Results**
- b.report "public_suffix" do
- LOOPS.times do
- DOMAINS.each do |domain|
- PublicSuffix.parse(domain).domain rescue nil # it raises if not valid in any way, so we rescue it
- end
- end
- end
-
-end
```
+Ruby: MRI 2.0.0-p247
+ryodo (0.2.4.1)
+public_suffix (1.3.1)
+Machine: AMD Phenom(tm) II X6 1090T, 6 cores, 3.2 GHz; 8 GB RAM
+Linux 3.10.9-1-ARCH x86_64 GNU/Linux
-**Caveats**
+Benchmark of domain parsing
+===========================
-`PublicSuffix.parse(…)` will raise errors if domain input is invalid (e.g. not a registrable domain).
+Number of loops: 1000
+Number of items per loop: 100
-`Ryodo.parse(…)` won't raise but return nil values for invalid stuff (it only raises if input is not a String, of course).
+Rehearsal ---------------------------------------------------
+ryodo 2.780000 0.000000 2.780000 ( 2.779690)
+public_suffix 83.350000 0.000000 83.350000 ( 83.414578)
+----------------------------------------- total: 86.130000sec
-**Result**
+ user system total real
+ryodo 2.830000 0.000000 2.830000 ( 2.834630)
+public_suffix 83.450000 0.000000 83.450000 ( 83.510037)
+Ryodo vs. PublicSuffix
+
+Ryodo is 29.46 times faster than PublicSuffix.
+
```
-Rehearsal -------------------------------------------------
-ryodo 1.800000 0.000000 1.800000 ( 1.809521)
-public_suffix 21.880000 0.020000 21.900000 ( 21.907808)
---------------------------------------- total: 23.700000sec
- user system total real
-ryodo 1.770000 0.000000 1.770000 ( 1.769734)
-public_suffix 22.320000 0.010000 22.330000 ( 22.346013)
```
+Ruby: MRI 1.9.3-p448
+ryodo (0.2.4.1)
+public_suffix (1.3.1)
+Machine: AMD Phenom(tm) II X6 1090T, 6 cores, 3.2 GHz; 8 GB RAM
+Linux 3.10.9-1-ARCH x86_64 GNU/Linux
-As you can see, Ryodo is more than **10 times faster**.
+Benchmark of domain parsing
+===========================
-_(Funfact: My first approach was 6 times slower — improvement factor of 60!)_
+Number of loops: 1000
+Number of items per loop: 100
+Rehearsal ---------------------------------------------------
+ryodo 2.640000 0.000000 2.640000 ( 2.642131)
+public_suffix 80.710000 0.010000 80.720000 ( 80.770868)
+----------------------------------------- total: 83.360000sec
+ user system total real
+ryodo 2.670000 0.000000 2.670000 ( 2.664983)
+public_suffix 80.930000 0.020000 80.950000 ( 80.998667)
+Ryodo is 30.39 times faster than PublicSuffix.
+```
+Interestingly the public_suffix gem got even slower over time (and/or ruby versions)
+compared to my first benchmark (<http://codecraft.io/2012/06/02/ryodo-domain-parser/>).
+
+
+
## TODO
Lot of specs missing, this first version of second approach was developed in playground mode. ;o)
@@ -224,5 +238,9 @@
## License
MIT/X11 — see [`LICENSE`](./LICENSE)
(c) 2012—2013 Christoph Grabo
+
+
+[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/asaaki/ryodo/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
+