* A basic search for one single entry
*/
@Test
public void testSearchPerfObjectScope() throws Exception
{
LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );
EntryCursor cursor = connection.search( "uid=admin,ou=system", "(ObjectClass=*)",
SearchScope.OBJECT, "*" );
int i = 0;
while ( cursor.next() )
{
cursor.get();
++i;
}
cursor.close();
assertEquals( 1, i );
int nbIterations = 1500000;
Dn dn = new Dn( getService().getSchemaManager(), "uid=admin,ou=system" );
SearchRequest searchRequest = new SearchRequestImpl();
searchRequest.setBase( dn );
searchRequest.setFilter( "(ObjectClass=*)" );
searchRequest.setScope( SearchScope.OBJECT );
searchRequest.addAttributes( "*" );
searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );
long t0 = System.currentTimeMillis();
long t00 = 0L;
long tt0 = System.currentTimeMillis();
int count = 0;
for ( i = 0; i < nbIterations; i++ )
{
if ( i % 100000 == 0 )
{
long tt1 = System.currentTimeMillis();
System.out.println( i + ", " + ( tt1 - tt0 ) );
tt0 = tt1;
}
if ( i == 500000 )
{
t00 = System.currentTimeMillis();
}
cursor = new EntryCursorImpl( connection.search( searchRequest ) );
while ( cursor.next() )
{
cursor.get();
count++;
}
cursor.close();
}
long t1 = System.currentTimeMillis();
Long deltaWarmed = ( t1 - t00 );
System.out.println( "OBJECT level - Delta : " + deltaWarmed + "( "
+ ( ( ( nbIterations - 500000 ) * 1000 ) / deltaWarmed )
+ " per s ) /" + ( t1 - t0 ) + ", count : " + count );
connection.close();
}