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/08/21 18:50:51 UTC
svn commit: r234263 - in
/directory/shared/ldap/branches/new-codec-integration/apache2-provider: ./
perfs/ perfs/org/ perfs/org/apache/ perfs/org/apache/asn1new/
perfs/org/apache/asn1new/ber/
perfs/org/apache/asn1new/ber/LdapDecoderPerf.java
Author: elecharny
Date: Sun Aug 21 09:50:47 2005
New Revision: 234263
URL: http://svn.apache.org/viewcvs?rev=234263&view=rev
Log:
Creation
Added:
directory/shared/ldap/branches/new-codec-integration/apache2-provider/
directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/
directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/
directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/
directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/asn1new/
directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/asn1new/ber/
directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/asn1new/ber/LdapDecoderPerf.java
Added: 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=234263&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/asn1new/ber/LdapDecoderPerf.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/perfs/org/apache/asn1new/ber/LdapDecoderPerf.java Sun Aug 21 09:50:47 2005
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.asn1new.ber;
+
+import org.apache.asn1new.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.log4j.PropertyConfigurator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.nio.ByteBuffer;
+
+
+/**
+ * A performance test.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+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 ------------------------------------------------------------------------------------
+
+ /**
+ * A performance test...
+ */
+ public void run()
+ {
+ Asn1Decoder ldapDecoder = new LdapDecoder();
+
+ 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'
+ } );
+
+ stream.flip();
+
+ try
+ {
+
+ long t0 = System.currentTimeMillis();
+
+ for ( int i = 0; i < 1000000; 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.
+ stream.flip();
+ }
+
+ long t1 = System.currentTimeMillis();
+
+ System.out.println( "Delta = " + ( t1 - t0 ) );
+ }
+ 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() );
+ de.printStackTrace();
+ }
+ }
+
+ /**
+ * Main
+ *
+ * @param args DOCUMENT ME!
+ */
+ public static void main( String[] args )
+ {
+
+ LdapDecoderPerf ldpt1 = new LdapDecoderPerf();
+ LdapDecoderPerf ldpt2 = new LdapDecoderPerf();
+ LdapDecoderPerf ldpt3 = new LdapDecoderPerf();
+ LdapDecoderPerf ldpt4 = new LdapDecoderPerf();
+
+ ldpt1.start();
+ ldpt2.start();
+ ldpt3.start();
+ ldpt4.start();
+ }
+}