@Test
@Ignore
public void testAddPerf() throws Exception
{
Dn dn = new Dn( "cn=test,ou=system" );
Entry entry = new DefaultEntry( getService().getSchemaManager(), dn,
"ObjectClass: top",
"ObjectClass: person",
"sn: TEST",
"cn: test" );
connection.add( entry );
int nbIterations = 8000;
//BufferedWriter out = new BufferedWriter( new FileWriter("/tmp/out.txt") );
long t0 = System.currentTimeMillis();
long t00 = 0L;
long tt0 = System.currentTimeMillis();
for ( int i = 0; i < nbIterations; i++ )
{
if ( i % 1000 == 0 )
{
long tt1 = System.currentTimeMillis();
System.out.println( i + ", " + ( tt1 - tt0 ) );
tt0 = tt1;
}
if ( i == 500 )
{
t00 = System.currentTimeMillis();
}
dn = new Dn( "uid=" + i + ",dc=example,dc=com" );
entry = new DefaultEntry(
getService().getSchemaManager(),
dn,
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid",
Integer.toString( i ),
"mail: A-A-R.Awg-Rosli@acme.com",
"title: Snr Operations Technician (D)",
"sn: Awg-Rosli",
"departmentNumber: SMDS - UIA/G/MMO52D",
"cn: Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D",
"description: UI - S",
"telephoneNumber: 555-1212",
"givenName: Awg-Abd-Rahim",
"businessCategory: Ops MDS (Malaysia) Sdn Bhd",
"displayName",
i + "Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D",
"employeeNumber: A-A-R.Awg-Rosli",
"pwdPolicySubEntry: ads-pwdId=cproint,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config" );
//out.write( LdifUtils.convertToLdif( entry ) );
connection.add( entry );
}
//out.flush();
//out.close();
long t1 = System.currentTimeMillis();
Long deltaWarmed = ( t1 - t00 );
System.out.println( "Delta : " + deltaWarmed + "( " + ( ( ( nbIterations - 500 ) * 1000 ) / deltaWarmed )
+ " per s ) /" + ( t1 - t0 ) );
Entry entry1 = null;
Entry entry2 = null;
Entry entry3 = null;
long ns0 = System.currentTimeMillis();
EntryCursor results = connection.search( "dc=example,dc=com",
"(displayName=1234Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D)", SearchScope.SUBTREE, "*" );