Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 47218 invoked from network); 4 Sep 2005 09:16:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Sep 2005 09:16:45 -0000 Received: (qmail 34795 invoked by uid 500); 4 Sep 2005 09:16:45 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 34738 invoked by uid 500); 4 Sep 2005 09:16:44 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 34724 invoked by uid 99); 4 Sep 2005 09:16:44 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 04 Sep 2005 02:16:44 -0700 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 04 Sep 2005 02:16:58 -0700 Received: (qmail 47198 invoked by uid 65534); 4 Sep 2005 09:16:43 -0000 Message-ID: <20050904091643.47197.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r278566 - /directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/asn1new/ber/LdapDecoderPerf.java Date: Sun, 04 Sep 2005 09:16:42 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: elecharny Date: Sun Sep 4 02:16:37 2005 New Revision: 278566 URL: http://svn.apache.org/viewcvs?rev=278566&view=rev Log: - Changed the BindRequest to a SearchResultEntry, more realistic. - Changes the log initialization Modified: directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/asn1new/ber/LdapDecoderPerf.java Modified: directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/asn1new/ber/LdapDecoderPerf.java URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/asn1new/ber/LdapDecoderPerf.java?rev=278566&r1=278565&r2=278566&view=diff ============================================================================== --- directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/asn1new/ber/LdapDecoderPerf.java (original) +++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/asn1new/ber/LdapDecoderPerf.java Sun Sep 4 02:16:37 2005 @@ -18,16 +18,13 @@ import org.apache.asn1.codec.DecoderException; import org.apache.asn1new.ber.Asn1Decoder; -import org.apache.asn1new.ber.containers.IAsn1Container; import org.apache.asn1new.ldap.codec.LdapDecoder; import org.apache.asn1new.ldap.codec.LdapMessageContainer; import org.apache.asn1new.ldap.pojo.BindRequest; import org.apache.asn1new.ldap.pojo.LdapMessage; -import org.apache.asn1new.ldap.pojo.SimpleAuthentication; - +import org.apache.asn1new.ldap.pojo.SearchResultEntry; +import org.apache.log4j.BasicConfigurator; import org.apache.log4j.PropertyConfigurator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.nio.ByteBuffer; @@ -39,16 +36,6 @@ */ public class LdapDecoderPerf extends Thread { - //~ Static fields/initializers ----------------------------------------------------------------- - - /** Logger */ - protected static Logger log = LoggerFactory.getLogger( LdapDecoderPerf.class ); - - static - { - PropertyConfigurator.configure( "conf/log4j-perf.conf" ); - } - //~ Methods ------------------------------------------------------------------------------------ /** @@ -56,44 +43,79 @@ */ public void run() { - Asn1Decoder ldapDecoder = new LdapDecoder(); + PropertyConfigurator.configure( System.getProperty( "log4j.configuration" ) ); + + Asn1Decoder ldapDecoder = new LdapDecoder(); + + ByteBuffer stream = ByteBuffer.allocate( 0x7b ); + - ByteBuffer stream = ByteBuffer.allocate( 0x35 ); stream.put( new byte[] { - 0x30, 0x33, // LDAPMessage ::=SEQUENCE { - 0x02, 0x01, 0x01, // messageID MessageID - 0x60, 0x2E, // CHOICE { ..., bindRequest BindRequest, ... - // BindRequest ::= APPLICATION[0] SEQUENCE { - 0x02, 0x01, 0x03, // version INTEGER (1..127), - 0x04, 0x1F, // name LDAPDN, - 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', - 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', - ( byte ) 0x80, 0x08, // authentication AuthenticationChoice - // AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING, ... - 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' + 0x30, 0x79, // LDAPMessage ::=SEQUENCE { + 0x02, 0x01, 0x01, // messageID MessageID + 0x64, 0x74, // CHOICE { ..., searchResEntry SearchResultEntry, ... + // SearchResultEntry ::= [APPLICATION 4] SEQUENCE { + // objectName LDAPDN, + 0x04, 0x1b, 'o', 'u', '=', 'c', 'o', 'n', 't', 'a', 'c', 't', 's', ',', 'd', 'c', '=', 'i', 'k', 't', 'e', 'k', ',', 'd', 'c', '=', 'c', 'o', 'm', + // attributes PartialAttributeList } + // PartialAttributeList ::= SEQUENCE OF SEQUENCE { + 0x30, 0x55, + 0x30, 0x28, + // type AttributeDescription, + 0x04, 0x0b, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's', + // vals SET OF AttributeValue } + 0x31, 0x19, + // AttributeValue ::= OCTET STRING + 0x04, 0x03, 't', 'o', 'p', + // AttributeValue ::= OCTET STRING + 0x04, 0x12, 'o', 'r', 'g', 'a', 'n', 'i', 'z', 'a', 't', 'i', 'o', 'n', 'a', 'l', 'U', 'n', 'i', 't', + 0x30, 0x29, + // type AttributeDescription, + 0x04, 0x0c, 'o', 'b', 'j', 'e', 'c', 't', 'c', 'l', 'a', 's', 's', '2', + // vals SET OF AttributeValue } + 0x31, 0x19, + // AttributeValue ::= OCTET STRING + 0x04, 0x03, 't', 'o', 'p', + // AttributeValue ::= OCTET STRING + 0x04, 0x12, 'o', 'r', 'g', 'a', 'n', 'i', 'z', 'a', 't', 'i', 'o', 'n', 'a', 'l', 'U', 'n', 'i', 't' } ); +/* + stream.put( + new byte[] + { + 0x30, 0x33, // LDAPMessage ::=SEQUENCE { + 0x02, 0x01, 0x01, // messageID MessageID + 0x60, 0x2E, // CHOICE { ..., bindRequest BindRequest, ... + // BindRequest ::= APPLICATION[0] SEQUENCE { + 0x02, 0x01, 0x03, // version INTEGER (1..127), + 0x04, 0x1F, // name LDAPDN, + 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd', 'c', '=', + 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', + ( byte ) 0x80, 0x08, // authentication AuthenticationChoice + // AuthenticationChoice ::= CHOICE { simple [0] OCTET STRING, ... + 'p', 'a', 's', 's', 'w', 'o', 'r', 'd' + } ); +*/ stream.flip(); try { long t0 = System.currentTimeMillis(); + LdapMessageContainer ldapMessageContainer = new LdapMessageContainer(); - for ( int i = 0; i < 1000000; i++ ) + for ( int i = 0; i < 100000; i++ ) { - //log.debug( "---------------------> " + i ); - // Allocate a BindRequest Container - IAsn1Container ldapMessageContainer = new LdapMessageContainer(); ldapDecoder.decode( stream, ldapMessageContainer ); - // Free the BindRequest Container. It will be put back in the IPool - // after being reset. + // Restore the buffer, and reset the container stream.flip(); + ldapMessageContainer.clean(); } long t1 = System.currentTimeMillis(); @@ -102,36 +124,7 @@ } catch ( DecoderException de ) { - log.error( de.getMessage() ); - de.printStackTrace(); - } - - try - { - - IAsn1Container ldapMessageContainer = new LdapMessageContainer(); - - ldapDecoder.decode( stream, ldapMessageContainer ); - - // Free the BindRequest Container. It will be put back in the IPool - // after being reset. - //bindRequestContainer.free(); - LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ) - .getLdapMessage(); - BindRequest br = message.getBindRequest(); - - System.out.println( "BindRequest decoded :" ); - System.out.println( " MessageId = " + message.getMessageId() ); - System.out.println( " Version = " + br.getVersion() ); - System.out.println( " Name = " + br.getName() ); - System.out.println( " Authentication = " + - ( ( br.getAuthentication() instanceof SimpleAuthentication ) ? "Simple" : "sasl" ) ); - System.out.println( " simple = " + - ( ( SimpleAuthentication ) br.getAuthentication() ).getSimple() ); - } - catch ( DecoderException de ) - { - log.error( de.getMessage() ); + System.out.println( de.getMessage() ); de.printStackTrace(); } }