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


001:        package org.apache.lucene.benchmark.byTask.stats;
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 org.apache.lucene.benchmark.byTask.tasks.PerfTask;
021:
022:        /**
023:         * Statistics for a task run. 
024:         * <br>The same task can run more than once, but, if that task records statistics, 
025:         * each run would create its own TaskStats.
026:         */
027:        public class TaskStats implements  Cloneable {
028:
029:            /** task for which data was collected */
030:            private PerfTask task;
031:
032:            /** round in which task run started */
033:            private int round;
034:
035:            /** task start time */
036:            private long start;
037:
038:            /** task elapsed time.  elapsed >= 0 indicates run completion! */
039:            private long elapsed = -1;
040:
041:            /** max tot mem during task */
042:            private long maxTotMem;
043:
044:            /** max used mem during task */
045:            private long maxUsedMem;
046:
047:            /** serial run number of this task run in the perf run */
048:            private int taskRunNum;
049:
050:            /** number of other tasks that started to run while this task was still running */
051:            private int numParallelTasks;
052:
053:            /** number of work items done by this task.
054:             * For indexing that can be number of docs added.
055:             * For warming that can be number of scanned items, etc. 
056:             * For repeating tasks, this is a sum over repetitions.
057:             */
058:            private int count;
059:
060:            /** Number of similar tasks aggregated into this record.   
061:             * Used when summing up on few runs/instances of similar tasks.
062:             */
063:            private int numRuns = 1;
064:
065:            /**
066:             * Create a run data for a task that is starting now.
067:             * To be called from Points.
068:             */
069:            TaskStats(PerfTask task, int taskRunNum, int round) {
070:                this .task = task;
071:                this .taskRunNum = taskRunNum;
072:                this .round = round;
073:                maxTotMem = Runtime.getRuntime().totalMemory();
074:                maxUsedMem = maxTotMem - Runtime.getRuntime().freeMemory();
075:                start = System.currentTimeMillis();
076:            }
077:
078:            /**
079:             * mark the end of a task
080:             */
081:            void markEnd(int numParallelTasks, int count) {
082:                elapsed = System.currentTimeMillis() - start;
083:                long totMem = Runtime.getRuntime().totalMemory();
084:                if (totMem > maxTotMem) {
085:                    maxTotMem = totMem;
086:                }
087:                long usedMem = totMem - Runtime.getRuntime().freeMemory();
088:                if (usedMem > maxUsedMem) {
089:                    maxUsedMem = usedMem;
090:                }
091:                this .numParallelTasks = numParallelTasks;
092:                this .count = count;
093:            }
094:
095:            /**
096:             * @return the taskRunNum.
097:             */
098:            public int getTaskRunNum() {
099:                return taskRunNum;
100:            }
101:
102:            /* (non-Javadoc)
103:             * @see java.lang.Object#toString()
104:             */
105:            public String toString() {
106:                StringBuffer res = new StringBuffer(task.getName());
107:                res.append(" ");
108:                res.append(count);
109:                res.append(" ");
110:                res.append(elapsed);
111:                return res.toString();
112:            }
113:
114:            /**
115:             * @return Returns the count.
116:             */
117:            public int getCount() {
118:                return count;
119:            }
120:
121:            /**
122:             * @return elapsed time.
123:             */
124:            public long getElapsed() {
125:                return elapsed;
126:            }
127:
128:            /**
129:             * @return Returns the maxTotMem.
130:             */
131:            public long getMaxTotMem() {
132:                return maxTotMem;
133:            }
134:
135:            /**
136:             * @return Returns the maxUsedMem.
137:             */
138:            public long getMaxUsedMem() {
139:                return maxUsedMem;
140:            }
141:
142:            /**
143:             * @return Returns the numParallelTasks.
144:             */
145:            public int getNumParallelTasks() {
146:                return numParallelTasks;
147:            }
148:
149:            /**
150:             * @return Returns the task.
151:             */
152:            public PerfTask getTask() {
153:                return task;
154:            }
155:
156:            /**
157:             * @return Returns the numRuns.
158:             */
159:            public int getNumRuns() {
160:                return numRuns;
161:            }
162:
163:            /**
164:             * Add data from another stat, for aggregation
165:             * @param stat2 the added stat data.
166:             */
167:            public void add(TaskStats stat2) {
168:                numRuns += stat2.getNumRuns();
169:                elapsed += stat2.getElapsed();
170:                maxTotMem += stat2.getMaxTotMem();
171:                maxUsedMem += stat2.getMaxUsedMem();
172:                count += stat2.getCount();
173:                if (round != stat2.round) {
174:                    round = -1; // no meaning if agregating tasks of different ruond. 
175:                }
176:            }
177:
178:            /* (non-Javadoc)
179:             * @see java.lang.Object#clone()
180:             */
181:            public Object clone() throws CloneNotSupportedException {
182:                return super .clone();
183:            }
184:
185:            /**
186:             * @return the round number.
187:             */
188:            public int getRound() {
189:                return round;
190:            }
191:
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.