|
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 BenchmarkRunner implements Runnable |
|
19 { |
|
20 private Thread myThread; |
|
21 private RmsBenchmarkMidlet myMIDlet; |
|
22 private boolean runFullTests; |
|
23 |
|
24 public static final String TESTNAMES = "RMS,,,,\n"; |
|
25 public static final String TESTS = |
|
26 "10 byte record create,10 byte enumerated read,10 byte random read,create enums,10 byte record set,open,close,10 byte record delete" + |
|
27 ",,100 byte record create,100 byte enumerated read,100 byte random read,create enums,100 byte record set,open,close,100 byte record delete" + |
|
28 ",,1000 byte record create,1000 byte enumerated read,1000 byte random read,create enums,1000 byte record set,open,close,1000 byte record delete" + |
|
29 ",,10000 byte record create,10000 byte enumerated read,10000 byte random read,create enums,10000 byte record set,open,close,10000 byte record delete" + |
|
30 ",,100000 byte record create,100000 byte enumerated read,100000 byte random read,create enums,100000 byte record set,open,close,100000 byte record delete\n"; |
|
31 |
|
32 public static StringBuffer SCORES; |
|
33 |
|
34 BenchmarkRunner(RmsBenchmarkMidlet aMIDlet) |
|
35 { |
|
36 myMIDlet = aMIDlet; |
|
37 SCORES = new StringBuffer(); |
|
38 } |
|
39 |
|
40 public void start() |
|
41 { |
|
42 runFullTests = false; |
|
43 System.out.println("BenchmarkRunner.start()"); |
|
44 myThread = new Thread(this); |
|
45 myThread.start(); |
|
46 } |
|
47 |
|
48 public void startFull() |
|
49 { |
|
50 runFullTests = true; |
|
51 System.out.println("BenchmarkRunner.startFull()"); |
|
52 myThread = new Thread(this); |
|
53 myThread.start(); |
|
54 } |
|
55 |
|
56 private void getScores(Benchmark benchmark) |
|
57 { |
|
58 StringBuffer score = new StringBuffer(); |
|
59 while (benchmark.getScore(score)) |
|
60 { |
|
61 SCORES.append(score.toString()); |
|
62 SCORES.append(','); |
|
63 score.delete(0, score.length()); |
|
64 } |
|
65 } |
|
66 |
|
67 public void run() |
|
68 { |
|
69 System.out.println("BenchmarkRunner.run()"); |
|
70 SCORES.delete(0, SCORES.length()); |
|
71 |
|
72 Benchmark benchmark; |
|
73 |
|
74 // RMS BENCHMARK |
|
75 myMIDlet.updateForm("RMS..."); |
|
76 benchmark = new RMSBenchmark(runFullTests); |
|
77 benchmark.runTest(); |
|
78 getScores(benchmark); |
|
79 benchmark = null; |
|
80 System.gc(); |
|
81 |
|
82 SCORES.append('\n'); // EOL |
|
83 Printer printer = new Printer(); |
|
84 printer.print(); |
|
85 |
|
86 myMIDlet.testsCompleted(); |
|
87 System.out.println("BenchmarkRunner.run() completed"); |
|
88 } |
|
89 |
|
90 } |