From: Chris R. <Chr...@me...> - 2000-07-27 09:23:16
|
On Wed, 26 Jul 2000 18:31:18 CDT, Luke Kanies wrote: > Hi all. I have some questions about perceived speed of Net::LDAP. I > ran some quick comparisons between it and the command line, and am > willing to do more if anyone wants more info. > > My problem is that Net::LDAP appears to be about an order of magnitude > slower for search operations than the corresponding command line > function. Mark's already commented that one of the bottlenecks is Net::LDAP's use of a perl module for decoding the BER (ie Convert::ASN1). Writing a Convert::ASN1 in C is a way around this, but as yet no-one has volunteered. Another obvious issue with perl is that the first run of a piece of code might be slow because it makes perl load in, parse and compile lots more chunks of perl. So you really need to make your perl test program do the same thing a couple of times without quitting the interpreter, and then ignore the first result. It is also worth removing the stepping through the results and the output parts of each test to see how that affects things - obviously real world programs will step through results and do interesting stuff, but it'd be interesting to see where most of the slowdown is. > For instance, I have an ldap database with 1768 ou's in it, and I > performed three different types of searches on it using both the command > line and Net::LDAP. First I just dumped all of the entries to the > screen; then I built a hash of all of the entries, of the form > $hash{$dn}->{$attr} = $value. Finally, I did another search and just > counted the entries. > > For the command line functions, to dump to screen I just used system(), > to build the hash, I used open() and then match and split, and to count > I used open() and counted blank lines. > > For Net::LDAP, to dump I did the search and cycled through the entries > with $entry->dump, to build the hash, I cycled through and used: > $dn = $entry->dn; > foreach $attr ($entry->attributes) > { > $hash{$dn}->{$attr} = $entry->get($attr); > } > > and for counting, I just did a $count++ for each entry. > > For each Net::LDAP search I opened and closed the connection for each > time test. > > Here are the numbers that I found: > > Net: dump 21 > Net: hash 14 > Net: count 16 > CLI: dump 2 > CLI: hash 1 > CLI: count 1 For what it is worth, I don't find Net::LDAP to be unusably slow - the nice API and the portability make up for a lot. Cheers, Chris |