You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2003/06/09 14:06:30 UTC

cvs commit: db-ojb/src/test/org/apache/ojb/broker PerformanceTest3.java PerformanceTest2.java

arminw      2003/06/09 05:06:30

  Modified:    .        build.xml
               src/test/org/apache/ojb/performance PerfTest.java
                        PerfMain.java PerfHandle.java PerfArticleImpl.java
                        PerfArticle.java
               src/test/org/apache/ojb/broker PerformanceTest3.java
                        PerformanceTest2.java
  Log:
  - use Thread.join() to enable
  main thread wait for client threads
  - fix performance3 test
  
  Revision  Changes    Path
  1.89      +1 -2      db-ojb/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/build.xml,v
  retrieving revision 1.88
  retrieving revision 1.89
  diff -u -r1.88 -r1.89
  --- build.xml	9 Jun 2003 10:41:33 -0000	1.88
  +++ build.xml	9 Jun 2003 12:06:29 -0000	1.89
  @@ -902,8 +902,7 @@
   			<arg value="100"/> <!-- iterations per thread, default was 100 -->
               <arg value="false"/> <!-- if 'false' we use autoincrement key generation, default false -->
               <arg value="3"/> <!-- 1 = PB-test, 2 = ODMG-test, 3 = Both, default was 3 -->
  -            <arg value="repositoryFarAway.xml"/> <!-- repository of second database -->
  -            <arg value="3"/> <!-- Number of test loops, default was 3 -->
  +            <arg value="2"/> <!-- Number of test loops, default was 3 -->
               <jvmarg value="-Xms128m"/>
               <jvmarg value="-Xmx256m"/>
           </java>
  
  
  
  1.5       +117 -56   db-ojb/src/test/org/apache/ojb/performance/PerfTest.java
  
  Index: PerfTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/performance/PerfTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PerfTest.java	7 Jun 2003 10:23:36 -0000	1.4
  +++ PerfTest.java	9 Jun 2003 12:06:29 -0000	1.5
  @@ -1,9 +1,58 @@
  -/*
  - * Date: 08.07.2002
  - * Time: 19:43:51
  - */
   package org.apache.ojb.performance;
   
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
  + *    written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
  + *    prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
   
   /**
    * Derivate this class to implement a test instance for the performance test.
  @@ -27,6 +76,10 @@
       private PerfMain perfMain;
       private long perfTestId;
       private boolean checked;
  +    /**
  +     * The threads that are executing.
  +     */
  +    private Thread threads[] = null;
   
       public PerfTest()
       {
  @@ -65,6 +118,54 @@
           checked = true;
       }
   
  +    /**
  +     * Interrupt the running threads.
  +     */
  +    protected void interruptThreads()
  +    {
  +        if (threads != null)
  +        {
  +            for (int i = 0; i < threads.length; i++)
  +            {
  +                threads[i].interrupt();
  +            }
  +        }
  +        System.err.println("## Test failed! ##");
  +        System.err.println("## Test failed! ##");
  +    }
  +
  +    /**
  +     * Run the threads.
  +     */
  +    protected void runTestHandles(final PerfHandle[] runnables)
  +    {
  +        if (runnables == null)
  +        {
  +            throw new IllegalArgumentException("runnables is null");
  +        }
  +        threads = new Thread[runnables.length];
  +        for (int i = 0; i < threads.length; i++)
  +        {
  +            threads[i] = new Thread(runnables[i]);
  +        }
  +        for (int i = 0; i < threads.length; i++)
  +        {
  +            threads[i].start();
  +        }
  +        try
  +        {
  +            for (int i = 0; i < threads.length; i++)
  +            {
  +                threads[i].join();
  +            }
  +        }
  +        catch (InterruptedException ignore)
  +        {
  +            System.out.println("Thread join interrupted.");
  +        }
  +        threads = null;
  +    }
  +
       public void performTest()
       {
           try
  @@ -83,18 +184,19 @@
               threadCount = PerfMain.getConcurrentThreads();
   
               objectCount = articleCount();
  -            testMultithreaded();
  -            while (threadGroup.activeCount() > activeThreadsStart)
  +
  +            // now we start the test threads
  +            PerfHandle[] perfHandles = new PerfHandle[PerfMain.getConcurrentThreads()];
  +            for (int i = 0; i < PerfMain.getConcurrentThreads(); i++)
               {
  -                System.out.println(PREFIX_LOG + "active threads/base threads: " + threadGroup.activeCount() + " / " + activeThreadsStart);
  -                try
  -                {
  -                    Thread.sleep(1500);
  -                }
  -                catch (InterruptedException e)
  -                {
  -                }
  +                PerfHandle ph = newPerfHandle(this);
  +                perfHandles[i] = ph;
               }
  +            testTimes[0] = System.currentTimeMillis();
  +            runTestHandles(perfHandles);
  +            testTimes[0] = (long) (System.currentTimeMillis() - testTimes[0]);
  +            // end of test threads
  +
               objectCountAfter = articleCount();
               perfMain.addPeriodResult(testName(), testTimes);
               perfMain.addConsistentResult(testName(), objectCount, objectCountAfter);
  @@ -109,47 +211,6 @@
       public void registerException(String causer, Exception e)
       {
           perfMain.registerException(causer, e);
  -    }
  -
  -    public void testMultithreaded()
  -    {
  -        testTimes[0] = System.currentTimeMillis();
  -        for (int i = 0; i < PerfMain.getConcurrentThreads(); i++)
  -        {
  -            PerfHandle ph = newPerfHandle(this);
  -            new Thread(threadGroup, ph).start();
  -        }
  -        System.out.print("+");
  -        while (activeThreads(false) > 0)
  -        {
  -            //loop till all threads ended
  -            //method activeThreads "suspend" (call wait)
  -            //this thread,
  -            //cause we do not want to trace this loop
  -        }
  -        testTimes[0] = (long) (System.currentTimeMillis() - testTimes[0]);
  -    }
  -
  -    public synchronized int activeThreads(boolean notify)
  -    {
  -        try
  -        {
  -            //freeze main thread, we only want to trace client threads
  -            if (!notify)
  -                wait();
  -            else
  -                notifyAll();
  -        }
  -        catch (InterruptedException e)
  -        {
  -        }
  -        System.out.print(".");
  -        return this.threadCount;
  -    }
  -
  -    public synchronized void checkOut()
  -    {
  -        --threadCount;
       }
   
       public synchronized void addTime(int position, long time)
  
  
  
  1.4       +63 -9     db-ojb/src/test/org/apache/ojb/performance/PerfMain.java
  
  Index: PerfMain.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/performance/PerfMain.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PerfMain.java	7 Jun 2003 10:23:01 -0000	1.3
  +++ PerfMain.java	9 Jun 2003 12:06:29 -0000	1.4
  @@ -1,5 +1,59 @@
   package org.apache.ojb.performance;
   
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
  + *    written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
  + *    prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +
   import java.io.OutputStream;
   import java.io.PrintStream;
   import java.util.ArrayList;
  @@ -215,7 +269,7 @@
           StringBuffer buf = new StringBuffer();
           // table header
           buf.append(EOL);
  -        for(int i=0;i<5;i++)
  +        for (int i = 0; i < 5; i++)
           {
               buf.append(getFilledUpToLength("", column, "="));
           }
  @@ -228,9 +282,9 @@
                   PerfMain.getIterationsPerThread() + " objects per thread");
           buf.append(EOL);
           buf.append(getFilledUpToLength("", column, " "));
  -        buf.append("- " + (isUseStressMode()==false ? "performance mode" : "stress mode -"));
  +        buf.append("- " + (isUseStressMode() == false ? "performance mode" : "stress mode -"));
           buf.append(EOL);
  -        for(int i=0;i<5;i++)
  +        for (int i = 0; i < 5; i++)
           {
               buf.append(getFilledUpToLength("", column, "="));
           }
  @@ -247,14 +301,14 @@
           buf.append(getFilledUpToLength("[msec]", column, " "));
           buf.append(getFilledUpToLength("[msec]", column, " "));
           buf.append(EOL);
  -        for(int i=0;i<5;i++)
  +        for (int i = 0; i < 5; i++)
           {
               buf.append(getFilledUpToLength("", column, "-"));
           }
   
           // fill table
           Iterator it = results.iterator();
  -        while(it.hasNext())
  +        while (it.hasNext())
           {
               buf.append(EOL);
               PerfResult res = (PerfResult) it.next();
  @@ -265,7 +319,7 @@
               buf.append(getFilledUpToLength(new Long(res.getDeletePeriod()).toString(), column, " "));
           }
           buf.append(EOL);
  -        for(int i=0;i<5;i++)
  +        for (int i = 0; i < 5; i++)
           {
               buf.append(getFilledUpToLength("", column, "="));
           }
  @@ -274,11 +328,11 @@
   
       private String getFilledUpToLength(String target, int length, String fillCharacter)
       {
  -        if(target.length() > length) return target;
  +        if (target.length() > length) return target;
   
           int count = length - target.length();
           String blanks = "";
  -        for(int i=0;i<count;i++)
  +        for (int i = 0; i < count; i++)
           {
               blanks = blanks + fillCharacter;
           }
  
  
  
  1.6       +57 -7     db-ojb/src/test/org/apache/ojb/performance/PerfHandle.java
  
  Index: PerfHandle.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/performance/PerfHandle.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PerfHandle.java	7 Jun 2003 10:21:46 -0000	1.5
  +++ PerfHandle.java	9 Jun 2003 12:06:29 -0000	1.6
  @@ -1,8 +1,62 @@
   package org.apache.ojb.performance;
   
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
  + *    written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
  + *    prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +
  +import java.math.BigDecimal;
   import java.util.Collection;
   import java.util.Iterator;
  -import java.math.BigDecimal;
   
   /**
    * Derivate this class to implement a test client for the performance test.
  @@ -174,11 +228,7 @@
           {
               e.printStackTrace();
               test.registerException(test.testName(), e);
  -        }
  -        finally
  -        {
  -            test.checkOut();
  -            test.activeThreads(true);
  +            test.interruptThreads();
           }
       }
   
  
  
  
  1.2       +55 -1     db-ojb/src/test/org/apache/ojb/performance/PerfArticleImpl.java
  
  Index: PerfArticleImpl.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/performance/PerfArticleImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PerfArticleImpl.java	6 Feb 2003 01:20:54 -0000	1.1
  +++ PerfArticleImpl.java	9 Jun 2003 12:06:29 -0000	1.2
  @@ -1,5 +1,59 @@
   package org.apache.ojb.performance;
   
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
  + *    written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
  + *    prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +
   import java.math.BigDecimal;
   
   /**
  
  
  
  1.3       +56 -2     db-ojb/src/test/org/apache/ojb/performance/PerfArticle.java
  
  Index: PerfArticle.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/performance/PerfArticle.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PerfArticle.java	29 Apr 2003 15:43:27 -0000	1.2
  +++ PerfArticle.java	9 Jun 2003 12:06:29 -0000	1.3
  @@ -1,7 +1,61 @@
   package org.apache.ojb.performance;
   
  -import java.math.BigDecimal;
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution,
  + *    if any, must include the following acknowledgment:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowledgment may appear in the software itself,
  + *    if and wherever such third-party acknowledgments normally appear.
  + *
  + * 4. The names "Apache" and "Apache Software Foundation" and
  + *    "Apache ObjectRelationalBridge" must not be used to endorse or promote products
  + *    derived from this software without prior written permission. For
  + *    written permission, please contact apache@apache.org.
  + *
  + * 5. Products derived from this software may not be called "Apache",
  + *    "Apache ObjectRelationalBridge", nor may "Apache" appear in their name, without
  + *    prior written permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
  +
   import java.io.Serializable;
  +import java.math.BigDecimal;
   
   /**
    * Persistent object interface.
  
  
  
  1.8       +88 -99    db-ojb/src/test/org/apache/ojb/broker/PerformanceTest3.java
  
  Index: PerformanceTest3.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PerformanceTest3.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- PerformanceTest3.java	7 Jun 2003 10:18:11 -0000	1.7
  +++ PerformanceTest3.java	9 Jun 2003 12:06:29 -0000	1.8
  @@ -1,7 +1,3 @@
  -/*
  - * Date: 08.07.2002
  - * Time: 19:43:51
  - */
   package org.apache.ojb.broker;
   
   import org.apache.ojb.broker.query.Criteria;
  @@ -47,9 +43,11 @@
        */
       private long[] times;
       private int threadCount;
  -    private Logger log = LoggerFactory.getLogger(PerformanceTest3.class);
       public ThreadGroup threadGroup = new ThreadGroup("PerfTest");
  -//    private String repository;
  +    /**
  +     * The threads that are executing.
  +     */
  +    private Thread threads[] = null;
   
       public PerformanceTest3()
       {
  @@ -58,7 +56,7 @@
   
       public static void main(String[] args)
       {
  -        int loops = args.length > 5 ? Integer.parseInt(args[5]) : 1;
  +        int loops = args.length > 4 ? Integer.parseInt(args[4]) : 1;
           System.out.println("#######################################" +
                   "\n###  Start stress test - do " + loops + " loop  ###" +
                   "\n#######################################");
  @@ -88,10 +86,6 @@
           {
               whichTest = Integer.parseInt(args[3]);
           }
  -        if (args.length > 4)
  -        {
  -            databaseNameFarAway = args[4];
  -        }
           try
           {
               PerformanceTest3 test = new PerformanceTest3();
  @@ -102,24 +96,10 @@
   
               if (whichTest == 1 || whichTest == 3)
               {
  -
  -                int activeThreadsStart = test.threadGroup.activeCount();
                   test.init();
                   objectCountDefault = test.getArticleCount();
                   objectCountFarAway = test.getFarAwayCount();
                   test.testMultithreaded_PB_api();
  -                int count;
  -                while (test.threadGroup.activeCount() > activeThreadsStart)
  -                {
  -                    System.err.println("# active threads: " + test.threadGroup.activeCount());
  -                    try
  -                    {
  -                        Thread.sleep(1500);
  -                    }
  -                    catch (InterruptedException e)
  -                    {
  -                    }
  -                }
   
                   System.err.println("Test-Info:   Objects in default DB before PB test: " + objectCountDefault);
                   objectCountDefaultAfter = test.getArticleCount();
  @@ -136,23 +116,11 @@
   
               if (whichTest == 2 || whichTest == 3)
               {
  -                int activeThreadsStart = test.threadGroup.activeCount();
                   test.init();
                   objectCountDefault = test.getArticleCount();
                   objectCountFarAway = test.getFarAwayCount();
                   test.testMultithreaded_ODMG_api();
  -                int count;
  -                while (test.threadGroup.activeCount() > activeThreadsStart)
  -                {
  -                    System.err.println("# active threads: " + test.threadGroup.activeCount());
  -                    try
  -                    {
  -                        Thread.sleep(1500);
  -                    }
  -                    catch (InterruptedException e)
  -                    {
  -                    }
  -                }
  +
                   System.err.println("Test-Info:   Objects in default DB before ODMG test: " + objectCountDefault);
                   objectCountDefaultAfter = test.getArticleCount();
                   System.err.println("Test-Info:   Objects in default DB after ODMG test: " + objectCountDefaultAfter);
  @@ -171,78 +139,98 @@
           }
       }
   
  -    public synchronized void checkOut()
  -    {
  -        --threadCount;
  -    }
  -
  -    public synchronized void addTime(int position, long time)
  +    /**
  +     * Interrupt the running threads.
  +     */
  +    protected void interruptThreads()
       {
  -        times[position] = times[position] + time;
  +        if (threads != null)
  +        {
  +            for (int i = 0; i < threads.length; i++)
  +            {
  +                threads[i].interrupt();
  +            }
  +        }
  +        System.err.println("## Test failed! ##");
  +        System.err.println("## Test failed! ##");
       }
   
  -    public synchronized int activeThreads(boolean notify)
  +    /**
  +     * Run the threads.
  +     */
  +    protected void runTestClients(final TestClient[] runnables)
       {
  +        if (runnables == null)
  +        {
  +            throw new IllegalArgumentException("runnables is null");
  +        }
  +        threads = new Thread[runnables.length];
  +        for (int i = 0; i < threads.length; i++)
  +        {
  +            threads[i] = new Thread(runnables[i]);
  +        }
  +        for (int i = 0; i < threads.length; i++)
  +        {
  +            threads[i].start();
  +        }
           try
           {
  -            //freeze main thread, we only want to trace client threads
  -            if (!notify)
  -                wait();
  -            else
  -                notifyAll();
  +            for (int i = 0; i < threads.length; i++)
  +            {
  +                threads[i].join();
  +            }
           }
  -        catch (InterruptedException e)
  +        catch (InterruptedException ignore)
           {
  +            System.out.println("Thread join interrupted.");
           }
  -        return this.threadCount;
  +        threads = null;
  +    }
  +
  +    public synchronized void addTime(int position, long time)
  +    {
  +        times[position] = times[position] + time;
       }
   
       public void testMultithreaded_PB_api()
       {
           String sep = System.getProperty("line.separator");
  -        times[0] = System.currentTimeMillis();
  -        log.info(sep + sep + "++ Start thread generation for PB api test ++");
  -        log.info("Begin with performance test, " + concurrentThreads +
  +
  +        System.out.println(sep + sep + "++ Start thread generation for PB api test ++");
  +        System.out.println("Begin with performance test, " + concurrentThreads +
                   " concurrent threads, handle " + iterationsPerThread + " articles form each thread");
  +        PerfomanceTestClientPB[] clientsPB = new PerfomanceTestClientPB[concurrentThreads];
           for (int i = 0; i < concurrentThreads; i++)
           {
  -            PerfomanceTestClientPB tc = new PerfomanceTestClientPB();
  -            new Thread(threadGroup, tc).start();
  -        }
  -        while (activeThreads(false) > 0)
  -        {
  -            //loop till all threads ended
  -            //method activeThreads "suspend" (call wait)
  -            //this thread,
  -            //cause we do not want to trace this loop
  +            PerfomanceTestClientPB obj = new PerfomanceTestClientPB(this);
  +            clientsPB[i] = obj;
           }
  +        System.out.println("");
  +        times[0] = System.currentTimeMillis();
  +        runTestClients(clientsPB);
           times[0] = (long) (System.currentTimeMillis() - times[0]);
  -        log.info(buildTestSummary("PB API"));
  -        log.info("++ End of performance test PB api ++" + sep + sep);
  +        System.out.println(buildTestSummary("PB API"));
  +        System.out.println("++ End of performance test PB api ++" + sep + sep);
       }
   
       public void testMultithreaded_ODMG_api()
       {
           String sep = System.getProperty("line.separator");
  -        times[0] = System.currentTimeMillis();
  -        log.info("++ Start thread generation for ODMG api test ++");
  -        log.info("Begin with performance test, " + concurrentThreads +
  +        System.out.println("++ Start thread generation for ODMG api test ++");
  +        System.out.println("Begin with performance test, " + concurrentThreads +
                   " concurrent threads, handle " + iterationsPerThread + " articles form each thread");
  +        PerfomanceTestClientODMG[] clientsODMG = new PerfomanceTestClientODMG[concurrentThreads];
           for (int i = 0; i < concurrentThreads; i++)
           {
  -            PerfomanceTestClientODMG tc = new PerfomanceTestClientODMG();
  -            new Thread(threadGroup, tc).start();
  -        }
  -        while (activeThreads(false) > 0)
  -        {
  -            //loop till all threads ended
  -            //method activeThreads "suspend" (call wait)
  -            //this thread,
  -            //cause we do not want to trace this loop
  +            PerfomanceTestClientODMG obj = new PerfomanceTestClientODMG(this);
  +            clientsODMG[i] = obj;
           }
  +        System.out.println("");
  +        times[0] = System.currentTimeMillis();
  +        runTestClients(clientsODMG);
           times[0] = (long) (System.currentTimeMillis() - times[0]);
  -        log.info(buildTestSummary("ODMG"));
  -        log.info("++ End of performance test ODMG api ++" + sep);
  +        System.out.println(buildTestSummary("ODMG"));
  +        System.out.println("++ End of performance test ODMG api ++" + sep);
       }
   
       private String buildTestSummary(String key)
  @@ -270,6 +258,11 @@
       }
   
   
  +    abstract class TestClient implements Runnable
  +    {
  +
  +    }
  +
   //*******************************************************************************************************
   //  Inner class ODMG test client
   //*******************************************************************************************************
  @@ -277,17 +270,18 @@
       /**
        * ODMG-api test class
        */
  -    class PerfomanceTestClientODMG implements Runnable
  +    class PerfomanceTestClientODMG extends TestClient
       {
           private PerformanceArticle[] arr;
           private FarAwayClass[] arrFarAway;
           private Implementation ojb;
           private static final String PRE_NAME = "A_";
           private String threadName;
  +        private PerformanceTest3 test;
   
  -        public PerfomanceTestClientODMG()
  +        public PerfomanceTestClientODMG(PerformanceTest3 test)
           {
  -
  +            this.test = test;
           }
   
           public void run()
  @@ -320,12 +314,9 @@
               }
               catch (Throwable e)
               {
  -                log.error("Error in client " + this, e);
  -            }
  -            finally
  -            {
  -                checkOut();
  -                activeThreads(true);
  +                e.printStackTrace();
  +                System.err.println("Error in client " + this);
  +                test.interruptThreads();
               }
           }
   
  @@ -485,18 +476,19 @@
   //*******************************************************************************************************
   //  Inner class PB test client
   //*******************************************************************************************************
  -
       /**
        * PB-api test class
        */
  -    class PerfomanceTestClientPB implements Runnable
  +    class PerfomanceTestClientPB extends TestClient
       {
           private PerformanceArticle[] arr;
           private FarAwayClass[] arrFarAway;
           private Implementation ojb;
  +        private PerformanceTest3 test;
   
  -        public PerfomanceTestClientPB()
  +        public PerfomanceTestClientPB(PerformanceTest3 test)
           {
  +            this.test = test;
               ojb = OJB.getInstance();
               arr = new PerformanceArticle[iterationsPerThread];
               for (int i = 0; i < iterationsPerThread; i++)
  @@ -528,12 +520,9 @@
               }
               catch (Throwable e)
               {
  -                log.error("Error in client " + this, e);
  -            }
  -            finally
  -            {
  -                checkOut();
  -                activeThreads(true);
  +                e.printStackTrace();
  +                System.err.println("Error in client " + this);
  +                test.interruptThreads();
               }
           }
   
  
  
  
  1.17      +95 -109   db-ojb/src/test/org/apache/ojb/broker/PerformanceTest2.java
  
  Index: PerformanceTest2.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PerformanceTest2.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- PerformanceTest2.java	7 Jun 2003 10:17:34 -0000	1.16
  +++ PerformanceTest2.java	9 Jun 2003 12:06:29 -0000	1.17
  @@ -43,9 +43,11 @@
        */
       private long[] times;
       private int threadCount;
  -    private Logger log = LoggerFactory.getLogger(PerformanceTest2.class);
  -    public ThreadGroup threadGroup = new ThreadGroup("PerfTest");
       private String databaseName = TestHelper.DEF_DATABASE_NAME;
  +    /**
  +     * The threads that are executing.
  +     */
  +    private Thread threads[] = null;
   
       public PerformanceTest2()
       {
  @@ -53,6 +55,54 @@
       }
   
       /**
  +     * Interrupt the running threads.
  +     */
  +    protected void interruptThreads()
  +    {
  +        if (threads != null)
  +        {
  +            for (int i = 0; i < threads.length; i++)
  +            {
  +                threads[i].interrupt();
  +            }
  +        }
  +        System.err.println("## Test failed! ##");
  +        System.err.println("## Test failed! ##");
  +    }
  +
  +    /**
  +     * Run the threads.
  +     */
  +    protected void runTestClients(final TestClient[] runnables)
  +    {
  +        if (runnables == null)
  +        {
  +            throw new IllegalArgumentException("runnables is null");
  +        }
  +        threads = new Thread[runnables.length];
  +        for (int i = 0; i < threads.length; i++)
  +        {
  +            threads[i] = new Thread(runnables[i]);
  +        }
  +        for (int i = 0; i < threads.length; i++)
  +        {
  +            threads[i].start();
  +        }
  +        try
  +        {
  +            for (int i = 0; i < threads.length; i++)
  +            {
  +                threads[i].join();
  +            }
  +        }
  +        catch (InterruptedException ignore)
  +        {
  +            System.out.println("Thread join interrupted.");
  +        }
  +        threads = null;
  +    }
  +
  +    /**
        * generate client made ids
        */
       public synchronized static int getId()
  @@ -78,49 +128,21 @@
           return count;
       }
   
  -    public ThreadGroup getThreadGroup()
  -    {
  -        return threadGroup;
  -    }
  -
  -    public synchronized void checkOut()
  -    {
  -        --threadCount;
  -    }
  -
       public synchronized void addTime(int position, long time)
       {
           times[position] = times[position] + time;
       }
   
  -    public synchronized int activeThreads(boolean notify)
  -    {
  -        try
  -        {
  -            //freeze main thread, we only want to trace client threads
  -            if (!notify)
  -                wait();
  -            else
  -                notifyAll();
  -        }
  -        catch (InterruptedException e)
  -        {
  -        }
  -        return this.threadCount;
  -    }
  -
       /**
        * Setting up the test fixture.
        */
       public void init() throws Exception
       {
  -//        log.info("Start init performance test");
           times = new long[4];
           threadCount = concurrentThreads;
   
           if (whichTest == 1 || whichTest == 3)
           {
  -//        log.info("Init PB-API");
               PerformanceArticle art = createArticle(1000);
               PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
               broker.beginTransaction();
  @@ -135,7 +157,6 @@
   
           if (whichTest == 2 || whichTest == 3)
           {
  -//        log.info("Init ODMG-API");
               PerformanceArticle art2 = createArticle(1001);
               Implementation ojb = OJB.getInstance();
               Database db = ojb.newDatabase();
  @@ -149,7 +170,6 @@
               db.deletePersistent(art2);
               tx.commit();
               db.close();
  -//        log.info("End init performance test");
           }
       }
   
  @@ -212,46 +232,22 @@
   
               if (whichTest == 1 || whichTest == 3)
               {
  -                int activeThreadsStart = test.threadGroup.activeCount();
                   test.init();
                   objectCount = test.getArticleCount();
                   test.testMultithreaded_PB_api();
  -                while (test.threadGroup.activeCount() > activeThreadsStart)
  -                {
  -                    System.err.println("# active threads: " + test.threadGroup.activeCount());
  -                    try
  -                    {
  -                        Thread.sleep(1500);
  -                    }
  -                    catch (InterruptedException e)
  -                    {
  -                    }
  -                }
   
  -                System.err.println("Test-Info:   Objects in DB before PB test: " + objectCount);
  +                System.out.println("Test-Info:   Objects in DB before PB test: " + objectCount);
                   objectCountAfter = test.getArticleCount();
  -                System.err.println("Test-Info:   Objects in DB after PB test: " + objectCountAfter);
  -                System.err.println("Test-Info:   Stress test was successful? - " + (objectCount == objectCountAfter) + " -");
  +                System.out.println("Test-Info:   Objects in DB after PB test: " + objectCountAfter);
  +                System.out.println("Test-Info:   Stress test was successful? - " + (objectCount == objectCountAfter) + " -");
               }
   
   
               if (whichTest == 2 || whichTest == 3)
               {
  -                int activeThreadsStart = test.threadGroup.activeCount();
                   test.init();
                   objectCount = test.getArticleCount();
                   test.testMultithreaded_ODMG_api();
  -                while (test.threadGroup.activeCount() > activeThreadsStart)
  -                {
  -                    System.err.println("# active threads: " + test.threadGroup.activeCount());
  -                    try
  -                    {
  -                        Thread.sleep(1500);
  -                    }
  -                    catch (InterruptedException e)
  -                    {
  -                    }
  -                }
   
                   System.err.println("Test-Info:   Objects in DB before ODMG test: " + objectCount);
                   objectCountAfter = test.getArticleCount();
  @@ -268,50 +264,42 @@
       public void testMultithreaded_PB_api()
       {
           String sep = System.getProperty("line.separator");
  -        times[0] = System.currentTimeMillis();
  -        log.info(sep + sep + "++ Start thread generation for PB api test ++");
  -        log.info("Begin with performance test, " + concurrentThreads +
  +
  +        System.out.println(sep + sep + "++ Start thread generation for PB api test ++");
  +        System.out.println("Begin with performance test, " + concurrentThreads +
                   " concurrent threads, handle " + iterationsPerThread + " articles form each thread");
  +        PerfomanceTestClientPB[] clientsPB = new PerfomanceTestClientPB[concurrentThreads];
           for (int i = 0; i < concurrentThreads; i++)
           {
  -            PerfomanceTestClientPB tc = new PerfomanceTestClientPB();
  -            new Thread(threadGroup, tc).start();
  +            PerfomanceTestClientPB obj = new PerfomanceTestClientPB(this);
  +            clientsPB[i] = obj;
           }
           System.out.println("");
  -        while (activeThreads(false) > 0)
  -        {
  -            //loop till all threads ended
  -            //method activeThreads "suspend" (call wait)
  -            //this thread,
  -            //cause we do not want to trace this loop
  -        }
  +        times[0] = System.currentTimeMillis();
  +        runTestClients(clientsPB);
           times[0] = (long) (System.currentTimeMillis() - times[0]);
  -        log.info(buildTestSummary("PB API"));
  -        log.info("++ End of performance test PB api ++" + sep + sep);
  +        System.out.println(buildTestSummary("PB API"));
  +        System.out.println("++ End of performance test PB api ++" + sep + sep);
       }
   
       public void testMultithreaded_ODMG_api()
       {
           String sep = System.getProperty("line.separator");
  -        times[0] = System.currentTimeMillis();
  -        log.info("++ Start thread generation for ODMG api test ++");
  -        log.info("Begin with performance test, " + concurrentThreads +
  +        System.out.println("++ Start thread generation for ODMG api test ++");
  +        System.out.println("Begin with performance test, " + concurrentThreads +
                   " concurrent threads, handle " + iterationsPerThread + " articles form each thread");
  +        PerfomanceTestClientODMG[] clientsODMG = new PerfomanceTestClientODMG[concurrentThreads];
           for (int i = 0; i < concurrentThreads; i++)
           {
  -            PerfomanceTestClientODMG tc = new PerfomanceTestClientODMG();
  -            new Thread(threadGroup, tc).start();
  -        }
  -        while (activeThreads(false) > 0)
  -        {
  -            //loop till all threads ended
  -            //method activeThreads "suspend" (call wait)
  -            //this thread,
  -            //cause we do not want to trace this loop
  +            PerfomanceTestClientODMG obj = new PerfomanceTestClientODMG(this);
  +            clientsODMG[i] = obj;
           }
  +        System.out.println("");
  +        times[0] = System.currentTimeMillis();
  +        runTestClients(clientsODMG);
           times[0] = (long) (System.currentTimeMillis() - times[0]);
  -        log.info(buildTestSummary("ODMG"));
  -        log.info("++ End of performance test ODMG api ++" + sep);
  +        System.out.println(buildTestSummary("ODMG"));
  +        System.out.println("++ End of performance test ODMG api ++" + sep);
       }
   
       private String buildTestSummary(String key)
  @@ -338,19 +326,26 @@
           return buf.toString();
       }
   
  +    abstract class TestClient implements Runnable
  +    {
  +
  +    }
  +
       /**
        * ODMG-api test class
        */
  -    class PerfomanceTestClientODMG implements Runnable
  +    class PerfomanceTestClientODMG extends TestClient
       {
           private static final String PRE_NAME = "A_";
           private PerformanceArticle[] arr;
           private Implementation odmg;
           private String threadName;
           private Database m_db;
  +        private PerformanceTest2 test;
   
  -        public PerfomanceTestClientODMG()
  +        public PerfomanceTestClientODMG(PerformanceTest2 test)
           {
  +            this.test = test;
           }
   
           public void run()
  @@ -364,7 +359,6 @@
                   arr[i] = a;
               }
   
  -            //log.info("Thread "+this+" run");
               try
               {
                   insertNewArticles();
  @@ -373,12 +367,9 @@
               }
               catch (Throwable e)
               {
  -                log.error("Error in client " + this, e);
  -            }
  -            finally
  -            {
  -                checkOut();
  -                activeThreads(true);
  +                System.out.println("Error in client " + this);
  +                e.printStackTrace();
  +                test.interruptThreads();
               }
           }
   
  @@ -468,24 +459,24 @@
       /**
        * PB-api test class
        */
  -    class PerfomanceTestClientPB implements Runnable
  +    class PerfomanceTestClientPB extends TestClient
       {
           private PerformanceArticle[] arr;
  +        private PerformanceTest2 test;
   
  -        public PerfomanceTestClientPB()
  +        public PerfomanceTestClientPB(PerformanceTest2 test)
           {
  +            this.test = test;
               arr = new PerformanceArticle[iterationsPerThread];
               for (int i = 0; i < iterationsPerThread; i++)
               {
                   PerformanceArticle a = createArticle(i);
                   arr[i] = a;
               }
  -            //log.info("Articles created");
           }
   
           public void run()
           {
  -            //log.info("Thread "+this+" run");
               try
               {
                   insertNewArticles();
  @@ -494,12 +485,9 @@
               }
               catch (Throwable e)
               {
  -                log.error("Error in client " + this, e);
  -            }
  -            finally
  -            {
  -                checkOut();
  -                activeThreads(true);
  +                System.out.println("Error in client " + this);
  +                e.printStackTrace();
  +                test.interruptThreads();
               }
           }
   
  @@ -600,8 +588,6 @@
               {
                   if (broker != null) broker.close();
               }
  -
  -
               long stop = System.currentTimeMillis();
               times[2] = times[2] + (stop - start);
           }