Source Code Cross Referenced for Benchmark.java in  » Search-Engine » lucene » org » apache » lucene » benchmark » byTask » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Search Engine » lucene » org.apache.lucene.benchmark.byTask 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.lucene.benchmark.byTask;
002:
003:        /**
004:         * Licensed to the Apache Software Foundation (ASF) under one or more
005:         * contributor license agreements.  See the NOTICE file distributed with
006:         * this work for additional information regarding copyright ownership.
007:         * The ASF licenses this file to You under the Apache License, Version 2.0
008:         * (the "License"); you may not use this file except in compliance with
009:         * the License.  You may obtain a copy of the License at
010:         *
011:         *     http://www.apache.org/licenses/LICENSE-2.0
012:         *
013:         * Unless required by applicable law or agreed to in writing, software
014:         * distributed under the License is distributed on an "AS IS" BASIS,
015:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016:         * See the License for the specific language governing permissions and
017:         * limitations under the License.
018:         */
019:
020:        import java.io.File;
021:        import java.io.FileReader;
022:        import java.io.Reader;
023:
024:        import org.apache.lucene.benchmark.byTask.utils.Algorithm;
025:        import org.apache.lucene.benchmark.byTask.utils.Config;
026:
027:        /**
028:         * Run the benchmark algorithm.
029:         * <p>Usage: java Benchmark  algorithm-file
030:         * <ol>
031:         * <li>Read algorithm.</li>
032:         * <li> Run the algorithm.</li>
033:         * </ol>
034:         * Things to be added/fixed in "Benchmarking by tasks":
035:         * <ol>
036:         * <li>TODO - report into Excel and/or graphed view.</li>
037:         * <li>TODO - perf comparison between Lucene releases over the years.</li>
038:         * <li>TODO - perf report adequate to include in Lucene nightly build site? (so we can easily track performance changes.)</li>
039:         * <li>TODO - add overall time control for repeated execution (vs. current by-count only).</li>
040:         * <li>TODO - query maker that is based on index statistics.</li>
041:         * </ol>
042:         */
043:        public class Benchmark {
044:
045:            private PerfRunData runData;
046:            private Algorithm algorithm;
047:            private boolean executed;
048:
049:            public Benchmark(Reader algReader) throws Exception {
050:                // prepare run data
051:                try {
052:                    runData = new PerfRunData(new Config(algReader));
053:                } catch (Exception e) {
054:                    e.printStackTrace();
055:                    throw new Exception("Error: cannot init PerfRunData!", e);
056:                }
057:
058:                // parse algorithm
059:                try {
060:                    algorithm = new Algorithm(runData);
061:                } catch (Exception e) {
062:                    throw new Exception("Error: cannot understand algorithm!",
063:                            e);
064:                }
065:            }
066:
067:            public synchronized void execute() throws Exception {
068:                if (executed) {
069:                    throw new IllegalStateException(
070:                            "Benchmark was already executed");
071:                }
072:                executed = true;
073:                runData.setStartTimeMillis();
074:                algorithm.execute();
075:            }
076:
077:            /**
078:             * Run the benchmark algorithm.
079:             * @param args benchmark config and algorithm files
080:             */
081:            public static void main(String[] args) {
082:                // verify command line args
083:                if (args.length < 1) {
084:                    System.err
085:                            .println("Usage: java Benchmark <algorithm file>");
086:                    System.exit(1);
087:                }
088:
089:                // verify input files 
090:                File algFile = new File(args[0]);
091:                if (!algFile.exists() || !algFile.isFile()
092:                        || !algFile.canRead()) {
093:                    System.err.println("cannot find/read algorithm file: "
094:                            + algFile.getAbsolutePath());
095:                    System.exit(1);
096:                }
097:
098:                System.out.println("Running algorithm from: "
099:                        + algFile.getAbsolutePath());
100:
101:                Benchmark benchmark = null;
102:                try {
103:                    benchmark = new Benchmark(new FileReader(algFile));
104:                } catch (Exception e) {
105:                    e.printStackTrace();
106:                    System.exit(1);
107:                }
108:
109:                System.out.println("------------> algorithm:");
110:                System.out.println(benchmark.getAlgorithm().toString());
111:
112:                // execute
113:                try {
114:                    benchmark.execute();
115:                } catch (Exception e) {
116:                    System.err.println("Error: cannot execute the algorithm! "
117:                            + e.getMessage());
118:                    e.printStackTrace();
119:                }
120:
121:                System.out.println("####################");
122:                System.out.println("###  D O N E !!! ###");
123:                System.out.println("####################");
124:
125:            }
126:
127:            /**
128:             * @return Returns the algorithm.
129:             */
130:            public Algorithm getAlgorithm() {
131:                return algorithm;
132:            }
133:
134:            /**
135:             * @return Returns the runData.
136:             */
137:            public PerfRunData getRunData() {
138:                return runData;
139:            }
140:
141:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.