javaextensions/midprms_db/tsrc/rmsbenchmark/javasrc/RMSBenchmark.java
branchRCL_3
changeset 19 04becd199f91
child 78 71ad690e91f5
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 public class RMSBenchmark implements Benchmark
       
    19 {
       
    20     private int NUMBER_OF_GETSCORE_REQUESTS = 0;
       
    21     private StringBuffer myScores[];
       
    22 
       
    23     private static final int[] quickTest = {100};
       
    24     private static final int[] fullTest = {10, 100, 1000, 10000, 100000};
       
    25     private int[] testSet;
       
    26 
       
    27     private int NUMBER_OF_TESTS = 9;
       
    28     private int NUMBER_OF_SCORES;// = NUMBER_OF_TESTS * testSet.length;
       
    29 
       
    30     RMSBenchmark(boolean aRunFullTests)
       
    31     {
       
    32         if (aRunFullTests)
       
    33         {
       
    34             testSet = new int[fullTest.length];
       
    35             System.arraycopy(fullTest, 0, testSet, 0, fullTest.length);
       
    36         }
       
    37         else
       
    38         {
       
    39             testSet = new int[quickTest.length];
       
    40             System.arraycopy(quickTest, 0, testSet, 0, quickTest.length);
       
    41         }
       
    42         NUMBER_OF_SCORES = NUMBER_OF_TESTS * testSet.length;
       
    43 
       
    44         myScores = new StringBuffer[NUMBER_OF_SCORES];
       
    45         for (int i = 0; i < myScores.length; i++)
       
    46         {
       
    47             myScores[i] = new StringBuffer();
       
    48         }
       
    49     }
       
    50 
       
    51     public void runTest()
       
    52     {
       
    53         System.out.println("RMSBenchmark.runTest()");
       
    54 
       
    55         for (int i = 0; i < testSet.length; i++)
       
    56         {
       
    57             System.out.println("loop start: "+i);
       
    58             Storage storage = new Storage(testSet[i]);
       
    59             myScores[i*NUMBER_OF_TESTS + 0].append(storage.createRecord());
       
    60             myScores[i*NUMBER_OF_TESTS + 1].append(storage.readEnumRecord());
       
    61             myScores[i*NUMBER_OF_TESTS + 2].append(storage.readRandomRecord());
       
    62             myScores[i*NUMBER_OF_TESTS + 3].append(storage.createEnum());
       
    63             myScores[i*NUMBER_OF_TESTS + 4].append(storage.setRecord());
       
    64             myScores[i*NUMBER_OF_TESTS + 5].append(storage.openStore());
       
    65             myScores[i*NUMBER_OF_TESTS + 6].append(storage.closeStore());
       
    66             myScores[i*NUMBER_OF_TESTS + 7].append(storage.deleteRecord());
       
    67             myScores[i*NUMBER_OF_TESTS + 8].append(""); // spacer
       
    68             storage.clean();
       
    69             System.out.println("loop done: "+i);
       
    70         }
       
    71 
       
    72         System.out.println("RMSBenchmark.runTest() completed");
       
    73     }
       
    74 
       
    75     public boolean getScore(StringBuffer score)
       
    76     {
       
    77         if (NUMBER_OF_GETSCORE_REQUESTS < NUMBER_OF_SCORES)
       
    78         {
       
    79             score.append(myScores[NUMBER_OF_GETSCORE_REQUESTS].toString());
       
    80             NUMBER_OF_GETSCORE_REQUESTS++;
       
    81             return true;
       
    82         }
       
    83         else
       
    84         {
       
    85             return false;
       
    86         }
       
    87     }
       
    88 }