Net::LDAP vs ruby/ldap

Discussion in 'Ruby' started by dacat, Apr 27, 2007.

  1. dacat

    dacat Guest

    The basic premise of this test was to see how long it would take to do
    the following:

    1000 Basic lookups on a known attribute/value pair over an unencrypted
    connection using anonymous bind for each library.

    This post is for informational purposes, I knew the NET::LDAP lib
    would be slower but I wanted to see by how much.
    {if you are new to ruby, the reason it is slower is because its a TRUE
    ruby implementation of the LDAP rfc. while on the other hand the ruby/
    ldap lib is a C front end to the openldap library}

    Bottom line is -- I just figured i would share.
    Code:
    ----------------
    require 'benchmark'
    include Benchmark

    LOOP_COUNT = 1000
    require 'ldap'
    require 'net/ldap'

    HOST = 'somehost.com'
    S_ATTR = 'some attribute that exists that can be lookedup'
    S_VAL = 'a value for the attribute that iss valid'
    TREE_BASE = 'a valid base ex. o=com'

    class LdapTest

    def net_ldap_test
    ldap = Net::LDAP.new :host => HOST, :port => 389
    filter = Net::LDAP::Filter.eq( S_ATTR, S_VAL )
    ldap.search( :base =>TREE_BASE, :filter => filter ) do |entry|
    a=entry.dn
    end
    nil
    end


    def ldap_test
    conn = LDAP::Conn.new(HOST, LDAP::LDAP_PORT)
    filter = "(#{S_ATTR}=#{S_VAL})"
    conn.search(TREE_BASE, LDAP::LDAP_SCOPE_SUBTREE, filter) do |entry|
    a=entry.dn
    end
    nil
    end

    ldap_test=LdapTest.new

    Benchmark.bm(15) do |x|
    x.report("NET::LDAP:") { for i in 1..LOOP_COUNT;
    ldap_test.net_ldap_test; end }
    x.report("ruby-ldap") { for i in 1..LOOP_COUNT ;
    ldap_test.ldap_test; end }
    end
    end
    ===============================================================

    My results.
    user system total real
    NET::LDAP: 7.150000 0.580000 7.730000 ( 19.494588)
    ruby-ldap 0.210000 0.120000 0.330000 ( 11.853484)


    ruby/ldap : http://ruby-ldap.sourceforge.net/
    net::ldap : http://rubyforge.org/projects/net-ldap/

    ruby --version
    ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
     
    dacat, Apr 27, 2007
    #1
    1. Advertising

  2. On Apr 27, 1:07 pm, dacat <> wrote:
    > The basic premise of this test was to see how long it would take to do
    > the following:
    >
    > 1000 Basic lookups on a known attribute/value pair over an unencrypted
    > connection using anonymous bind for each library.
    >
    > This post is for informational purposes, I knew the NET::LDAP lib
    > would be slower but I wanted to see by how much.
    > {if you are new to ruby, the reason it is slower is because its a TRUE
    > ruby implementation of the LDAP rfc. while on the other hand the ruby/
    > ldap lib is a C front end to the openldap library}
    >
    > Bottom line is -- I just figured i would share.
    > Code:
    > ----------------
    > require 'benchmark'
    > include Benchmark
    >
    > LOOP_COUNT = 1000
    > require 'ldap'
    > require 'net/ldap'
    >
    > HOST = 'somehost.com'
    > S_ATTR = 'some attribute that exists that can be lookedup'
    > S_VAL = 'a value for the attribute that iss valid'
    > TREE_BASE = 'a valid base ex. o=com'
    >
    > class LdapTest
    >
    > def net_ldap_test
    > ldap = Net::LDAP.new :host => HOST, :port => 389
    > filter = Net::LDAP::Filter.eq( S_ATTR, S_VAL )
    > ldap.search( :base =>TREE_BASE, :filter => filter ) do |entry|
    > a=entry.dn
    > end
    > nil
    > end
    >
    > def ldap_test
    > conn = LDAP::Conn.new(HOST, LDAP::LDAP_PORT)
    > filter = "(#{S_ATTR}=#{S_VAL})"
    > conn.search(TREE_BASE, LDAP::LDAP_SCOPE_SUBTREE, filter) do |entry|
    > a=entry.dn
    > end
    > nil
    > end
    >
    > ldap_test=LdapTest.new
    >
    > Benchmark.bm(15) do |x|
    > x.report("NET::LDAP:") { for i in 1..LOOP_COUNT;
    > ldap_test.net_ldap_test; end }
    > x.report("ruby-ldap") { for i in 1..LOOP_COUNT ;
    > ldap_test.ldap_test; end }
    > end
    > end
    > ===============================================================
    >
    > My results.
    > user system total real
    > NET::LDAP: 7.150000 0.580000 7.730000 ( 19.494588)
    > ruby-ldap 0.210000 0.120000 0.330000 ( 11.853484)
    >
    > ruby/ldap :http://ruby-ldap.sourceforge.net/
    > net::ldap :http://rubyforge.org/projects/net-ldap/
    >
    > ruby --version
    > ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]


    While it's interesting, I'm afraid I have to stick with net-ldap. The
    problem with ruby-ldap is that it segfaults in conjunction with
    WEBrick, as I know all too well.

    Regards,

    Dan
     
    Daniel Berger, Apr 27, 2007
    #2
    1. Advertising

  3. dacat

    Guest

    On Sat, 28 Apr 2007, Daniel Berger wrote:

    > On Apr 27, 1:07 pm, dacat <> wrote:
    >> The basic premise of this test was to see how long it would take to do
    >> the following:
    >>
    >> 1000 Basic lookups on a known attribute/value pair over an unencrypted
    >> connection using anonymous bind for each library.
    >>
    >> This post is for informational purposes, I knew the NET::LDAP lib
    >> would be slower but I wanted to see by how much.
    >> {if you are new to ruby, the reason it is slower is because its a TRUE
    >> ruby implementation of the LDAP rfc. while on the other hand the ruby/
    >> ldap lib is a C front end to the openldap library}
    >>
    >> Bottom line is -- I just figured i would share.
    >> Code:
    >> ----------------
    >> require 'benchmark'
    >> include Benchmark
    >>
    >> LOOP_COUNT = 1000
    >> require 'ldap'
    >> require 'net/ldap'
    >>
    >> HOST = 'somehost.com'
    >> S_ATTR = 'some attribute that exists that can be lookedup'
    >> S_VAL = 'a value for the attribute that iss valid'
    >> TREE_BASE = 'a valid base ex. o=com'
    >>
    >> class LdapTest
    >>
    >> def net_ldap_test
    >> ldap = Net::LDAP.new :host => HOST, :port => 389
    >> filter = Net::LDAP::Filter.eq( S_ATTR, S_VAL )
    >> ldap.search( :base =>TREE_BASE, :filter => filter ) do |entry|
    >> a=entry.dn
    >> end
    >> nil
    >> end
    >>
    >> def ldap_test
    >> conn = LDAP::Conn.new(HOST, LDAP::LDAP_PORT)
    >> filter = "(#{S_ATTR}=#{S_VAL})"
    >> conn.search(TREE_BASE, LDAP::LDAP_SCOPE_SUBTREE, filter) do |entry|
    >> a=entry.dn
    >> end
    >> nil
    >> end
    >>
    >> ldap_test=LdapTest.new
    >>
    >> Benchmark.bm(15) do |x|
    >> x.report("NET::LDAP:") { for i in 1..LOOP_COUNT;
    >> ldap_test.net_ldap_test; end }
    >> x.report("ruby-ldap") { for i in 1..LOOP_COUNT ;
    >> ldap_test.ldap_test; end }
    >> end
    >> end
    >> ===============================================================
    >>
    >> My results.
    >> user system total real
    >> NET::LDAP: 7.150000 0.580000 7.730000 ( 19.494588)
    >> ruby-ldap 0.210000 0.120000 0.330000 ( 11.853484)
    >>
    >> ruby/ldap :http://ruby-ldap.sourceforge.net/
    >> net::ldap :http://rubyforge.org/projects/net-ldap/
    >>
    >> ruby --version
    >> ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]

    >
    > While it's interesting, I'm afraid I have to stick with net-ldap. The
    > problem with ruby-ldap is that it segfaults in conjunction with
    > WEBrick, as I know all too well.
    >
    > Regards,
    >
    > Dan


    my good friend justin crawford works heavily with ruby and ldap for the
    universtiy of colorado managing a huge federated authentication system. they
    use the pure ruby ldap lib because the c version is unstable. he's been using
    it for several years on a system that's serving ~ 100,000 people - so i think
    it's fast enough.

    fyi.

    -a
    --
    be kind whenever possible... it is always possible.
    - the dalai lama
     
    , Apr 27, 2007
    #3
  4. On Apr 27, 10:16 pm, wrote:

    > my good friend justin crawford works heavily with ruby and ldap for the
    > universtiy of colorado managing a huge federated authentication system. they
    > use the pure ruby ldap lib because the c version is unstable. he's been using
    > it for several years on a system that's serving ~ 100,000 people - so i think
    > it's fast enough.


    I'd be interested to discover exactly what "unstable" means here, so
    that I can fix the problem.

    I'd also like to see code that can reproduce the segfault in
    combination with WEBRick.

    Thanks,

    Ian
     
    Ian Macdonald, May 18, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    533
    Raymond DeCampo
    Feb 21, 2006
  2. Jason Wold

    using LDAP Controls in ruby-ldap

    Jason Wold, Nov 4, 2004, in forum: Ruby
    Replies:
    5
    Views:
    252
  3. Ian Macdonald
    Replies:
    0
    Views:
    218
    Ian Macdonald
    Mar 15, 2005
  4. James Hughes
    Replies:
    4
    Views:
    329
    James Hughes
    Dec 13, 2005
  5. Replies:
    1
    Views:
    210
    Austin Ziegler
    Oct 11, 2006
Loading...

Share This Page