File: ClassStats.java

package info (click to toggle)
libequinox-osgi-java 3.9.1-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 5,068 kB
  • sloc: java: 57,768; makefile: 9
file content (121 lines) | stat: -rw-r--r-- 3,058 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*******************************************************************************
 * Copyright (c) 2000, 2010 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.core.runtime.internal.stats;

import java.util.ArrayList;
import java.util.List;

/**
 * Maintain statistics about a loaded class.
 */
public class ClassStats {
	private String className; // fully qualified name of this class 
	private ClassloaderStats classloader; // the classloader that loaded this class
	private int loadOrder = -1;

	private long timestamp; // time at which this class was loaded
	private long timeLoading; // time to load the class
	private long timeLoadingOthers = 0; // time spent loading classes which has been triggered by this class  

	// parentage of classes loaded
	private ClassStats loadedBy = null; // a reference to the class that loaded this class
	private List<ClassStats> loaded = new ArrayList<ClassStats>(2); // a reference to the classes that this class loaded

	private boolean duringStartup; // indicate if the class was loaded during platform startup

	//information to retrieve the stacktrace from the file
	private long traceStart = -1;
	private long traceEnd = -1;

	public ClassStats(String name, ClassloaderStats classloader) {
		className = name;
		timestamp = System.currentTimeMillis();
		duringStartup = StatsManager.isBooting();
		this.classloader = classloader;
	}

	public void setLoadOrder(int order) {
		loadOrder = order;
	}

	public void loadingDone() {
		timeLoading = System.currentTimeMillis() - timestamp;
	}

	public long getTimeLoading() {
		return timeLoading;
	}

	public long getLocalTimeLoading() {
		return timeLoading - timeLoadingOthers;
	}

	public void addTimeLoadingOthers(long time) {
		timeLoadingOthers = timeLoadingOthers + time;
	}

	public long getTraceStart() {
		return traceStart;
	}

	public long getTraceEnd() {
		return traceEnd;
	}

	public void setTraceStart(long position) {
		traceStart = position;
	}

	public void setTraceEnd(long position) {
		traceEnd = position;
	}

	public void loaded(ClassStats child) {
		loaded.add(child);
	}

	public void setLoadedBy(ClassStats parent) {
		loadedBy = parent;
	}

	public ClassStats getLoadedBy() {
		return loadedBy;
	}

	public List<ClassStats> getLoadedClasses() {
		return loaded;
	}

	public String getClassName() {
		return className;
	}

	public boolean isStartupClass() {
		return duringStartup;
	}

	public ClassloaderStats getClassloader() {
		return classloader;
	}

	public int getLoadOrder() {
		return loadOrder;
	}

	public long getTimestamp() {
		return timestamp;
	}

	public void toBaseClass() {
		duringStartup = true;
		loadOrder = -2;
	}
}