Why does writing STDOUT affect my Python LDAP performance?
Leif Hedstrom
leif at propel.com
Mon Feb 11 22:07:44 CET 2002
Hi,
I wanted to write a very small app to do some simple tests, and I got
some very, very strange results. I can't understand why the performance
is so abysmal unless I print on STDOUT... The script is something like:
#!/usr/bin/python2
import ldap
l = ldap.open("localhost")
l.simple_bind_s("", "")
loop = 1000
while loop:
loop = loop - 1
print "Going into LDAP, loop is ", loop
res = l.search_s(
"dc=propel,dc=com",
ldap.SCOPE_SUBTREE,
"cn=Manager"
)
print "Done with search"
l.unbind()
(I added the print statements to show my problem). Here are the time
resusts from two test runs:
269% time test.py
.
.
.
Done with search
2.180u 0.480s 0:06.85 38.8% 0+0k 0+0io 656pf+0w
loki 270% time /tmp/simple.py > /dev/null
115.770u 32.230s 2:31.46 97.7% 0+0k 0+0io 651pf+0w
Without redirecting STDOUT (lots of spam on the display), it takes about
6 secs, when I do redirect STDOUT to devnull it takes 150 seconds (25x
slower). This makes no sense to me at all... Also, this simple script
leaks memory, not sure where yet.
Any ideas where to look? I'm using Python 2.1.2, OpenLDAP 2.0.22 and
latest Python LDAP source from the CVS server.
Thanks,
-- leif
More information about the python-ldap
mailing list