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


001:        package org.apache.lucene.benchmark.stats;
002:
003:        /**
004:         * Copyright 2005 The Apache Software Foundation
005:         *
006:         * Licensed under the Apache License, Version 2.0 (the "License");
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         *
010:         *     http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         */
018:
019:        import java.util.LinkedHashMap;
020:        import java.util.Vector;
021:        import java.util.Collection;
022:        import java.util.Iterator;
023:
024:        /**
025:         * This class holds series of TimeData related to a single test run. TimeData
026:         * values may contribute to different measurements, so this class provides also
027:         * some useful methods to separate them.
028:         *
029:         * @author Andrzej Bialecki <ab@getopt.org>
030:         */
031:        public class TestRunData {
032:            private String id;
033:
034:            /** Start and end time of this test run. */
035:            private long start = 0L, end = 0L;
036:
037:            private LinkedHashMap data = new LinkedHashMap();
038:
039:            public TestRunData() {
040:            }
041:
042:            public TestRunData(String id) {
043:                this .id = id;
044:            }
045:
046:            public LinkedHashMap getData() {
047:                return data;
048:            }
049:
050:            public String getId() {
051:                return id;
052:            }
053:
054:            public void setId(String id) {
055:                this .id = id;
056:            }
057:
058:            public long getEnd() {
059:                return end;
060:            }
061:
062:            public long getStart() {
063:                return start;
064:            }
065:
066:            /** Mark the starting time of this test run. */
067:            public void startRun() {
068:                start = System.currentTimeMillis();
069:            }
070:
071:            /** Mark the ending time of this test run. */
072:            public void endRun() {
073:                end = System.currentTimeMillis();
074:            }
075:
076:            /** Add a data point. */
077:            public void addData(TimeData td) {
078:                td.recordMemUsage();
079:                Vector v = (Vector) data.get(td.name);
080:                if (v == null) {
081:                    v = new Vector();
082:                    data.put(td.name, v);
083:                }
084:                v.add(td.clone());
085:            }
086:
087:            /** Get a list of all available types of data points. */
088:            public Collection getLabels() {
089:                return data.keySet();
090:            }
091:
092:            /** Get total values from all data points of a given type. */
093:            public TimeData getTotals(String label) {
094:                Vector v = (Vector) data.get(label);
095:                if (v == null) {
096:                    return null;
097:                }
098:                TimeData res = new TimeData("TOTAL " + label);
099:                for (int i = 0; i < v.size(); i++) {
100:                    TimeData td = (TimeData) v.get(i);
101:                    res.count += td.count;
102:                    res.elapsed += td.elapsed;
103:                }
104:                return res;
105:            }
106:
107:            /** Get total values from all data points of all types.
108:             * @return a list of TimeData values for all types.
109:             */
110:            public Vector getTotals() {
111:                Collection labels = getLabels();
112:                Vector v = new Vector();
113:                Iterator it = labels.iterator();
114:                while (it.hasNext()) {
115:                    TimeData td = getTotals((String) it.next());
116:                    v.add(td);
117:                }
118:                return v;
119:            }
120:
121:            /** Get memory usage stats for a given data type. */
122:            public MemUsage getMemUsage(String label) {
123:                Vector v = (Vector) data.get(label);
124:                if (v == null) {
125:                    return null;
126:                }
127:                MemUsage res = new MemUsage();
128:                res.minFree = Long.MAX_VALUE;
129:                res.minTotal = Long.MAX_VALUE;
130:                long avgFree = 0L, avgTotal = 0L;
131:                for (int i = 0; i < v.size(); i++) {
132:                    TimeData td = (TimeData) v.get(i);
133:                    if (res.maxFree < td.freeMem) {
134:                        res.maxFree = td.freeMem;
135:                    }
136:                    if (res.maxTotal < td.totalMem) {
137:                        res.maxTotal = td.totalMem;
138:                    }
139:                    if (res.minFree > td.freeMem) {
140:                        res.minFree = td.freeMem;
141:                    }
142:                    if (res.minTotal > td.totalMem) {
143:                        res.minTotal = td.totalMem;
144:                    }
145:                    avgFree += td.freeMem;
146:                    avgTotal += td.totalMem;
147:                }
148:                res.avgFree = avgFree / v.size();
149:                res.avgTotal = avgTotal / v.size();
150:                return res;
151:            }
152:
153:            /** Return a string representation. */
154:            public String toString() {
155:                StringBuffer sb = new StringBuffer();
156:                Collection labels = getLabels();
157:                Iterator it = labels.iterator();
158:                while (it.hasNext()) {
159:                    String label = (String) it.next();
160:                    sb.append(id).append("-").append(label).append(" ").append(
161:                            getTotals(label).toString(false)).append(" ");
162:                    sb.append(
163:                            getMemUsage(label)
164:                                    .toScaledString(1024 * 1024, "MB")).append(
165:                            "\n");
166:                }
167:                return sb.toString();
168:            }
169:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.