Source Code Cross Referenced for ReportTask.java in  » Net » lucene-connector » org » apache » lucene » benchmark » byTask » tasks » 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 » Net » lucene connector » org.apache.lucene.benchmark.byTask.tasks 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.lucene.benchmark.byTask.tasks;
002:
003:        import java.util.Iterator;
004:        import java.util.LinkedHashMap;
005:
006:        import org.apache.lucene.benchmark.byTask.PerfRunData;
007:        import org.apache.lucene.benchmark.byTask.stats.Report;
008:        import org.apache.lucene.benchmark.byTask.stats.TaskStats;
009:        import org.apache.lucene.benchmark.byTask.utils.Format;
010:
011:        /**
012:         * Licensed to the Apache Software Foundation (ASF) under one or more
013:         * contributor license agreements.  See the NOTICE file distributed with
014:         * this work for additional information regarding copyright ownership.
015:         * The ASF licenses this file to You under the Apache License, Version 2.0
016:         * (the "License"); you may not use this file except in compliance with
017:         * the License.  You may obtain a copy of the License at
018:         *
019:         *     http://www.apache.org/licenses/LICENSE-2.0
020:         *
021:         * Unless required by applicable law or agreed to in writing, software
022:         * distributed under the License is distributed on an "AS IS" BASIS,
023:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
024:         * See the License for the specific language governing permissions and
025:         * limitations under the License.
026:         */
027:
028:        /**
029:         * Report (abstract) task - all report tasks extend this task.
030:         */
031:        public abstract class ReportTask extends PerfTask {
032:
033:            public ReportTask(PerfRunData runData) {
034:                super (runData);
035:            }
036:
037:            /* (non-Javadoc)
038:             * @see PerfTask#shouldNeverLogAtStart()
039:             */
040:            protected boolean shouldNeverLogAtStart() {
041:                return true;
042:            }
043:
044:            /* (non-Javadoc)
045:             * @see PerfTask#shouldNotRecordStats()
046:             */
047:            protected boolean shouldNotRecordStats() {
048:                return true;
049:            }
050:
051:            /*
052:             * From here start the code used to generate the reports. 
053:             * Subclasses would use this part to generate reports.
054:             */
055:
056:            protected static final String newline = System
057:                    .getProperty("line.separator");
058:
059:            /**
060:             * Get a textual summary of the benchmark results, average from all test runs.
061:             */
062:            protected static final String OP = "Operation  ";
063:            protected static final String ROUND = " round";
064:            protected static final String RUNCNT = "   runCnt";
065:            protected static final String RECCNT = "   recsPerRun";
066:            protected static final String RECSEC = "        rec/s";
067:            protected static final String ELAPSED = "  elapsedSec";
068:            protected static final String USEDMEM = "    avgUsedMem";
069:            protected static final String TOTMEM = "    avgTotalMem";
070:            protected static final String COLS[] = { RUNCNT, RECCNT, RECSEC,
071:                    ELAPSED, USEDMEM, TOTMEM };
072:
073:            /**
074:             * Compute a title line for a report table
075:             * @param longestOp size of longest op name in the table
076:             * @return the table title line.
077:             */
078:            protected String tableTitle(String longestOp) {
079:                StringBuffer sb = new StringBuffer();
080:                sb.append(Format.format(OP, longestOp));
081:                sb.append(ROUND);
082:                sb
083:                        .append(getRunData().getConfig()
084:                                .getColsNamesForValsByRound());
085:                for (int i = 0; i < COLS.length; i++) {
086:                    sb.append(COLS[i]);
087:                }
088:                return sb.toString();
089:            }
090:
091:            /**
092:             * find the longest op name out of completed tasks.  
093:             * @param taskStats completed tasks to be considered.
094:             * @return the longest op name out of completed tasks.
095:             */
096:            protected String longestOp(Iterator taskStats) {
097:                String longest = OP;
098:                while (taskStats.hasNext()) {
099:                    TaskStats stat = (TaskStats) taskStats.next();
100:                    if (stat.getElapsed() >= 0) { // consider only tasks that ended
101:                        String name = stat.getTask().getName();
102:                        if (name.length() > longest.length()) {
103:                            longest = name;
104:                        }
105:                    }
106:                }
107:                return longest;
108:            }
109:
110:            /**
111:             * Compute a report line for the given task stat.
112:             * @param longestOp size of longest op name in the table.
113:             * @param stat task stat to be printed.
114:             * @return the report line.
115:             */
116:            protected String taskReportLine(String longestOp, TaskStats stat) {
117:                PerfTask task = stat.getTask();
118:                StringBuffer sb = new StringBuffer();
119:                sb.append(Format.format(task.getName(), longestOp));
120:                String round = (stat.getRound() >= 0 ? "" + stat.getRound()
121:                        : "-");
122:                sb.append(Format.formatPaddLeft(round, ROUND));
123:                sb.append(getRunData().getConfig().getColsValuesForValsByRound(
124:                        stat.getRound()));
125:                sb.append(Format.format(stat.getNumRuns(), RUNCNT));
126:                sb.append(Format.format(stat.getCount() / stat.getNumRuns(),
127:                        RECCNT));
128:                long elapsed = (stat.getElapsed() > 0 ? stat.getElapsed() : 1); // assume at least 1ms
129:                sb.append(Format.format(1,
130:                        (float) (stat.getCount() * 1000.0 / elapsed), RECSEC));
131:                sb.append(Format.format(2, (float) stat.getElapsed() / 1000,
132:                        ELAPSED));
133:                sb.append(Format.format(0, (float) stat.getMaxUsedMem()
134:                        / stat.getNumRuns(), USEDMEM));
135:                sb.append(Format.format(0, (float) stat.getMaxTotMem()
136:                        / stat.getNumRuns(), TOTMEM));
137:                return sb.toString();
138:            }
139:
140:            protected Report genPartialReport(int reported,
141:                    LinkedHashMap partOfTasks, int totalSize) {
142:                String longetOp = longestOp(partOfTasks.values().iterator());
143:                boolean first = true;
144:                StringBuffer sb = new StringBuffer();
145:                sb.append(tableTitle(longetOp));
146:                sb.append(newline);
147:                int lineNum = 0;
148:                for (Iterator it = partOfTasks.values().iterator(); it
149:                        .hasNext();) {
150:                    TaskStats stat = (TaskStats) it.next();
151:                    if (!first) {
152:                        sb.append(newline);
153:                    }
154:                    first = false;
155:                    String line = taskReportLine(longetOp, stat);
156:                    lineNum++;
157:                    if (partOfTasks.size() > 2 && lineNum % 2 == 0) {
158:                        line = line.replaceAll("   ", " - ");
159:                    }
160:                    sb.append(line);
161:                }
162:                String reptxt = (reported == 0 ? "No Matching Entries Were Found!"
163:                        : sb.toString());
164:                return new Report(reptxt, partOfTasks.size(), reported,
165:                        totalSize);
166:            }
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.