directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r949943 - in /directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations: add/AddPerfIT.java modify/ModifyPerfIT.java
Date Tue, 01 Jun 2010 07:14:12 GMT
Author: elecharny
Date: Tue Jun  1 07:14:12 2010
New Revision: 949943

URL: http://svn.apache.org/viewvc?rev=949943&view=rev
Log:
Added perf tests

Added:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyPerfIT.java
Modified:
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/add/AddPerfIT.java

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/add/AddPerfIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/add/AddPerfIT.java?rev=949943&r1=949942&r2=949943&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/add/AddPerfIT.java
(original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/add/AddPerfIT.java
Tue Jun  1 07:14:12 2010
@@ -19,21 +19,18 @@
  */
 package org.apache.directory.server.core.operations.add;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
 
 import org.apache.directory.ldap.client.api.LdapConnection;
-import org.apache.directory.ldap.client.api.message.SearchResponse;
-import org.apache.directory.ldap.client.api.message.SearchResultEntry;
-import org.apache.directory.server.core.annotations.ApplyLdifs;
+import org.apache.directory.server.core.annotations.ContextEntry;
+import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.annotations.CreateIndex;
+import org.apache.directory.server.core.annotations.CreatePartition;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.core.integ.IntegrationUtils;
 import org.apache.directory.shared.ldap.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.name.DN;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -45,9 +42,30 @@ import org.junit.runner.RunWith;
  * @version $Rev$
  */
 @RunWith ( FrameworkRunner.class )
+@CreateDS(
+        name="AddPerfDS",
+        partitions =
+        {
+            @CreatePartition(
+                name = "example",
+                suffix = "dc=example,dc=com",
+                contextEntry = @ContextEntry( 
+                    entryLdif =
+                        "dn: dc=example,dc=com\n" +
+                        "dc: example\n" +
+                        "objectClass: top\n" +
+                        "objectClass: domain\n\n" ),
+                indexes = 
+                {
+                    @CreateIndex( attribute = "objectClass", cacheSize = 1000 ),
+                    @CreateIndex( attribute = "sn", cacheSize = 1000 ),
+                    @CreateIndex( attribute = "cn", cacheSize = 1000 )
+                } )
+                
+        },
+        enableChangeLog = false )
 public class AddPerfIT extends AbstractLdapTestUnit
 {
-
     /**
      * Test an add operation performance
      */
@@ -62,37 +80,37 @@ public class AddPerfIT extends AbstractL
         entry.add( "ObjectClass", "top", "person" );
         entry.add( "sn", "TEST" );
         entry.add( "cn", "test" );
-        
-        connection.add(entry );
-        
+
+        connection.add( entry );
+
         long t0 = System.currentTimeMillis();
         long tt0 = System.currentTimeMillis();
-        
+
         for ( int i = 0; i < 10000; i++ )
         {
-            if ( i% 100 == 0 )
+            if ( i % 100 == 0 )
             {
                 long tt1 = System.currentTimeMillis();
 
                 System.out.println( i + ", " + ( tt1 - tt0 ) );
                 tt0 = tt1;
             }
-            
+
             String name = "test" + i;
             dn = new DN( "cn=" + name + ",ou=system" );
             entry = new DefaultEntry( service.getSchemaManager(), dn );
             entry.add( "ObjectClass", "top", "person" );
             entry.add( "sn", name.toUpperCase() );
             entry.add( "cn", name );
-            
+
             long ttt0 = System.nanoTime();
-            connection.add(entry );
+            connection.add( entry );
             long ttt1 = System.nanoTime();
             //System.out.println("added " + i + ", delta = " + (ttt1-ttt0)/1000);
         }
-        
+
         long t1 = System.currentTimeMillis();
-        
+
         System.out.println( "Delta : " + ( t1 - t0 ) );
         connection.close();
     }

Added: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyPerfIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyPerfIT.java?rev=949943&view=auto
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyPerfIT.java
(added)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/modify/ModifyPerfIT.java
Tue Jun  1 07:14:12 2010
@@ -0,0 +1,117 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.directory.server.core.operations.modify;
+
+
+import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.ldap.client.api.message.ModifyRequest;
+import org.apache.directory.server.core.annotations.ContextEntry;
+import org.apache.directory.server.core.annotations.CreateDS;
+import org.apache.directory.server.core.annotations.CreateIndex;
+import org.apache.directory.server.core.annotations.CreatePartition;
+import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
+import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.server.core.integ.IntegrationUtils;
+import org.apache.directory.shared.ldap.entry.DefaultEntry;
+import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
+import org.apache.directory.shared.ldap.entry.DefaultModification;
+import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.name.DN;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Test the modify operation performances
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+@RunWith(FrameworkRunner.class)
+@CreateDS(name = "ModifyPerfDS", partitions =
+    { @CreatePartition(name = "example", suffix = "dc=example,dc=com", contextEntry = @ContextEntry(entryLdif
= "dn: dc=example,dc=com\n"
+        + "dc: example\n" + "objectClass: top\n" + "objectClass: domain\n\n"), indexes =
+        { @CreateIndex(attribute = "objectClass", cacheSize = 1000), @CreateIndex(attribute
= "sn", cacheSize = 1000),
+            @CreateIndex(attribute = "cn", cacheSize = 1000) })
+
+    }, enableChangeLog = false)
+public class ModifyPerfIT extends AbstractLdapTestUnit
+{
+    /**
+     * Test an modify operation performance
+     */
+    @Test
+    //@Ignore
+    public void testModifyPerf() throws Exception
+    {
+        LdapConnection connection = IntegrationUtils.getAdminConnection( service );
+
+        DN dn = new DN( "cn=test,ou=system" );
+        Entry entry = new DefaultEntry( service.getSchemaManager(), dn );
+        entry.add( "ObjectClass", "top", "person" );
+        entry.add( "sn", "TEST" );
+        entry.add( "cn", "test" );
+
+        connection.add( entry );
+
+        long t0 = System.currentTimeMillis();
+        long t00 = 0L;
+        long tt0 = System.currentTimeMillis();
+
+        for ( int i = 0; i < 1; i++ )
+        {
+            if ( i % 100 == 0 )
+            {
+                long tt1 = System.currentTimeMillis();
+
+                System.out.println( i + ", " + ( tt1 - tt0 ) );
+                tt0 = tt1;
+            }
+
+            if ( i == 10000 )
+            {
+                t00 = System.currentTimeMillis();
+            }
+
+            ModifyRequest modRequest = new ModifyRequest( dn );
+            Modification modification = new DefaultModification();
+            EntryAttribute attribute = new DefaultEntryAttribute( "sn" );
+
+            attribute.add( "test" + i );
+
+            modification.setAttribute( attribute );
+            modification.setOperation( ModificationOperation.REPLACE_ATTRIBUTE );
+            modRequest.addModification( modification );
+
+            long ttt0 = System.nanoTime();
+            connection.modify( modRequest );
+            long ttt1 = System.nanoTime();
+            //System.out.println("added " + i + ", delta = " + (ttt1-ttt0)/1000);
+        }
+
+        long t1 = System.currentTimeMillis();
+
+        System.out.println( "Delta : " + ( t1 - t00 ) + "/" + ( t1 - t0 ) );
+        connection.close();
+    }
+}



Mime
View raw message