avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/event/test FixedSizeQueueTestCase.java QueueTestCase.java
Date Wed, 19 Dec 2001 16:54:03 GMT
bloritsch    01/12/19 08:54:03

  Modified:    src/scratchpad/org/apache/avalon/excalibur/event
                        FixedSizeQueue.java
               src/scratchpad/org/apache/avalon/excalibur/event/test
                        FixedSizeQueueTestCase.java QueueTestCase.java
  Log:
  Fixed the FixedSize Queue, it is 30.88% more efficient than DefaultQueue
  
  Revision  Changes    Path
  1.2       +1 -1      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/event/FixedSizeQueue.java
  
  Index: FixedSizeQueue.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/event/FixedSizeQueue.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FixedSizeQueue.java	2001/12/18 22:11:52	1.1
  +++ FixedSizeQueue.java	2001/12/19 16:54:02	1.2
  @@ -26,7 +26,7 @@
   
       public FixedSizeQueue( int size )
       {
  -        m_elements = new QueueElement[ size ];
  +        m_elements = new QueueElement[ size + 1 ];
           m_mutex = new Mutex();
       }
   
  
  
  
  1.2       +1 -1      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/event/test/FixedSizeQueueTestCase.java
  
  Index: FixedSizeQueueTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/event/test/FixedSizeQueueTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FixedSizeQueueTestCase.java	2001/12/18 22:11:52	1.1
  +++ FixedSizeQueueTestCase.java	2001/12/19 16:54:02	1.2
  @@ -83,7 +83,7 @@
           for ( int j = 0; j < 1000000; j++ )
           {
               queue.enqueue( elements );
  -            assertEquals( 0, queue.size() );
  +            assertEquals( 10, queue.size() );
   
               QueueElement[] results = queue.dequeueAll();
               assertEquals( 10, results.length );
  
  
  
  1.3       +20 -20    jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/event/test/QueueTestCase.java
  
  Index: QueueTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/event/test/QueueTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- QueueTestCase.java	2001/12/18 21:09:28	1.2
  +++ QueueTestCase.java	2001/12/19 16:54:02	1.3
  @@ -62,15 +62,15 @@
           throws Exception
       {
           DefaultQueue queue = new DefaultQueue();
  -        assertEquals( queue.size(), 0 );
  +        assertEquals( 0, queue.size() );
   
           for ( int j = 0; j < 1000000; j++ )
           {
               queue.enqueue( element );
  -            assertEquals( queue.size(), 1 );
  +            assertEquals( 1, queue.size() );
   
               assertNotNull( queue.dequeue() );
  -            assertEquals( queue.size(), 0 );
  +            assertEquals( 0, queue.size() );
           }
       }
   
  @@ -78,56 +78,56 @@
           throws Exception
       {
           DefaultQueue queue = new DefaultQueue();
  -        assertEquals( queue.size(), 0 );
  +        assertEquals( 0, queue.size() );
   
           for ( int j = 0; j < 1000000; j++ )
           {
               queue.enqueue( elements );
  -            assertEquals( queue.size(), 10 );
  +            assertEquals( 10, queue.size() );
   
               QueueElement[] results = queue.dequeueAll();
  -            assertEquals( results.length, 10 );
  -            assertEquals( queue.size(), 0 );
  +            assertEquals( 10, results.length );
  +            assertEquals( 0, queue.size() );
           }
       }
   
       public void testDefaultQueue()
       {
           DefaultQueue queue = new DefaultQueue();
  -        assertEquals( queue.size(), 0 );
  +        assertEquals( 0, queue.size() );
   
           //test enqueue
           try
           {
               queue.enqueue( new TestQueueElement () );
  -            assertEquals( queue.size(), 1 );
  +            assertEquals( 1, queue.size() );
   
               assertNotNull( queue.dequeue() );
  -            assertEquals( queue.size(), 0 );
  +            assertEquals( 0, queue.size() );
   
               queue.enqueue( elements );
  -            assertEquals( queue.size(), 10 );
  +            assertEquals( 10, queue.size() );
   
               QueueElement[] results = queue.dequeue( 3 );
  -            assertEquals( results.length, 3 );
  -            assertEquals( queue.size(), 7 );
  +            assertEquals( 3, results.length );
  +            assertEquals( 7, queue.size() );
   
               results = queue.dequeueAll();
  -            assertEquals( results.length, 7 );
  -            assertEquals( queue.size(), 0 );
  +            assertEquals( 7, results.length );
  +            assertEquals( 0, queue.size() );
   
               PreparedEnqueue prep = queue.prepareEnqueue( elements );
  -            assertEquals( queue.size(), 0 );
  +            assertEquals( 0, queue.size() );
               prep.abort();
  -            assertEquals( queue.size(), 0 );
  +            assertEquals( 0, queue.size() );
   
               prep = queue.prepareEnqueue( elements );
  -            assertEquals( queue.size(), 0 );
  +            assertEquals( 0, queue.size() );
               prep.commit();
  -            assertEquals( queue.size(), 10 );
  +            assertEquals( 10, queue.size() );
   
               results = queue.dequeue( queue.size() );
  -            assertEquals( queue.size(), 0 );
  +            assertEquals( 0, queue.size() );
           }
           catch ( SourceException se )
           {
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message