You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2005/09/04 11:16:42 UTC
svn commit: r278566 -
/directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/asn1new/ber/LdapDecoderPerf.java
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();
}
}