Ruby wrapper for uriparser C library
C Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
benchmark
ext/uriparser_ext
lib
test
.gitignore
Gemfile
HISTORY.md
LICENSE
README.md
Rakefile
ruby-uriparser.gemspec

README.md

ruby-uriparser

Gem Version

Ruby-uriparser is a wrapper for uriparser C library which is fast (linear input length time complexity), approximatelly 7.5x faster than the standard ruby URI library with a low memory consumption.

It is a fairly reasonable hypothesis to consider that all Ruby Rack applications will call, at least once, the URI.parse method for each http request, so this simple optimization can bring a significant impact on a high load environment. (See Benchmark)

Usage

require 'uriparser'

UriParser.parse('https://localhost:9000/path/?a=1#x') # return UriParser::URI object

If you want to override the URI class just include the following line in your code:

# Will override URI#parse and Kernel#URI methods
require 'uriparser/uri_gem'

Benchmark

The following numbers were computed for 100,000 URI.parse calls using the ruby benchmark library in a Mac OS X (10.8.5)/ 2.9Ghz Intel Core I5/ 8GB 1600 MHz DDR3 machine:

Rehearsal ------------------------------------------------
URI            0.750000   0.000000   0.750000 (  0.750619)
UriParser      0.110000   0.010000   0.120000 (  0.111885)
Addressable    1.880000   0.000000   1.880000 (  1.886091)
--------------------------------------- total: 2.750000sec

                   user     system      total        real
URI            0.730000   0.000000   0.730000 (  0.728169)
UriParser      0.110000   0.000000   0.110000 (  0.107235)
Addressable    1.870000   0.000000   1.870000 (  1.863334)

Installation

gem install ruby-uriparser

External dependencies

The ruby-uriparser gems needs the library uriparser installed to compile.

See the availables ports list: http://uriparser.sourceforge.net/#ports.

If you are on Mac OS X just run brew install uriparser.

License

This project is released under the MIT license (See LICENSE file).

Copyright (c) 2014 Thiago Lewin - http://github.com/tlewin

Third party libraries

This project includes code from the New BSD licensed:

All rights reserved.