use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem in project memory-map-plugin by Praqma.
the class MemoryMapBuildAction method extractMaxValue.
private double extractMaxValue(MemoryMapConfigMemoryItem... item) {
double value = 0d;
String scale = getRecorder().getScale();
for (MemoryMapConfigMemoryItem it : item) {
if (getRecorder().getShowBytesOnGraph()) {
if (it.getTopLevelMemoryMax() != null) {
value = value + HexUtils.byteCount(it.getTopLevelMemoryMax(), getRecorder().getWordSize(), scale);
}
} else {
if (it.getTopLevelMemoryMax() != null) {
value = value + HexUtils.wordCount(it.getTopLevelMemoryMax(), scale);
}
}
}
return value;
}
use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem in project memory-map-plugin by Praqma.
the class MemoryMapBuildAction method extractMaxNonZeroValue.
private double extractMaxNonZeroValue(MemoryMapConfigMemoryItem... item) {
double value = 0d;
String scale = getRecorder().getScale();
for (MemoryMapConfigMemoryItem it : item) {
if (getRecorder().getShowBytesOnGraph()) {
if (it.getTopLevelMemoryMax() != null) {
value = value + HexUtils.byteCount(it.getTopLevelMemoryMax(), getRecorder().getWordSize(), scale);
if (value > 0d) {
return value;
}
}
} else {
if (it.getTopLevelMemoryMax() != null) {
value = value + HexUtils.wordCount(it.getTopLevelMemoryMax(), scale);
if (value > 0d) {
return value;
}
}
}
}
return value;
}
use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem in project memory-map-plugin by Praqma.
the class MemoryMapBuildAction method buildDataSet.
/**
* Builds the data set. Returns the maximum value.
*
* @param graphData GraphData
* @param dataSet the data set
* @param graphDataSet the graph data set
* @param markers markers to add (max values)
* @return a double with the value to be drawn on graph
*/
public double buildDataSet(List<String> graphData, String dataSet, DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> graphDataSet, HashMap<String, ValueMarker> markers) {
logger.log(Level.FINE, "Entering buildDataSet with data set {0}", dataSet);
double max = 0d;
for (String s : graphData) {
if (s.contains(" ")) {
String[] parts = s.split(" ");
String maxLabel = constructMaxLabel(parts);
String categoryLabel = constructCategoryLabel(parts);
for (MemoryMapBuildAction memBuild = this; memBuild != null; memBuild = memBuild.getPreviousAction()) {
logger.log(Level.FINE, "Building graph data set for build #{0}", memBuild.build.number);
MemoryMapConfigMemory result = memBuild.getMemoryMapConfigs().get(dataSet);
logger.log(Level.FINE, "Building MemoryMapConfig: {0}", result);
if (result == null) {
logger.log(Level.FINEST, "Data set {0} not found", dataSet);
for (String key : memBuild.getMemoryMapConfigs().keySet()) {
logger.log(Level.FINEST, "found {0}", key);
}
}
ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(memBuild.build);
if (result != null) {
List<MemoryMapConfigMemoryItem> ourItems = result.getItemByNames(parts);
MemoryMapConfigMemoryItem[] ourItemsArray = ourItems.toArray(new MemoryMapConfigMemoryItem[ourItems.size()]);
double value = extractValue(ourItemsArray);
boolean allBelongSameParent = MemoryMapConfigMemoryItem.allBelongSameParent(ourItemsArray);
if (allBelongSameParent) {
max = extractMaxNonZeroValue(ourItemsArray);
} else {
max = extractMaxValue(ourItemsArray);
}
graphDataSet.add(value, categoryLabel, label);
makeMarker(maxLabel, max, markers);
}
}
} else {
for (MemoryMapBuildAction memBuild = this; memBuild != null; memBuild = memBuild.getPreviousAction()) {
logger.log(Level.FINE, "Building graph data set for build #{0}", memBuild.build.number);
MemoryMapConfigMemory result = memBuild.getMemoryMapConfigs().get(dataSet);
logger.log(Level.FINE, "Building MemoryMapConfig: {0}", result);
if (result == null) {
logger.log(Level.FINEST, "Data set {0} not found", dataSet);
for (String key : memBuild.getMemoryMapConfigs().keySet()) {
logger.log(Level.FINEST, "found {0}", key);
}
}
ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(memBuild.build);
if (result != null) {
for (MemoryMapConfigMemoryItem item : result) {
if (item.getName().equals(s)) {
String maxLabel = constructMaxLabel(item.getName());
double newMax = extractMaxNonZeroValue(item);
double value = extractValue(item);
String categoryLabel = constructCategoryLabel(item.getName());
graphDataSet.add(value, categoryLabel, label);
if (newMax >= max) {
max = newMax;
}
if (newMax > 0d) {
makeMarker(maxLabel, newMax, markers);
}
}
}
}
}
}
}
return max;
}
use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem in project memory-map-plugin by Praqma.
the class MemoryMapBuildAction method extractValue.
/**
* Extracts the value from a given memory map item. If multiple objects are
* passed in, values get added.
*
* @param items the MemoryMapConfigMemoryItems to get the value of
* @return the value of the MemoryMapConfigMemoryItems
*/
private double extractValue(MemoryMapConfigMemoryItem... items) {
double value = 0d;
String scale = getRecorder().getScale();
for (MemoryMapConfigMemoryItem item : items) {
if (!StringUtils.isBlank(item.getUsed())) {
if (getRecorder().getShowBytesOnGraph()) {
value = value + HexUtils.byteCount(item.getUsed(), getRecorder().getWordSize(), scale);
} else {
value = value + HexUtils.wordCount(item.getUsed(), scale);
}
}
}
return value;
}
use of net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem in project memory-map-plugin by Praqma.
the class BuildResultValidator method getMemoryItems.
private HashMap<String, MemoryMapConfigMemoryItem> getMemoryItems(Run<?, ?> build) throws Exception {
HashMap<String, MemoryMapConfigMemoryItem> usageMap = new HashMap<>();
File buildFile = new File(build.getLogFile().getParent() + "/build.xml");
String fileF = FileUtils.readFileToString(buildFile);
System.out.println("===XML===");
System.out.println(fileF);
System.out.println("===XML===");
Document document = JsonParser.parseXml(buildFile);
NodeList allNodes = document.getElementsByTagName("*");
for (int i = 0; i < allNodes.getLength(); i++) {
if (allNodes.item(i).getNodeName().equals("net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem")) {
String nodeRaw = JsonParser.getRawXml(allNodes.item(i));
MemoryMapConfigMemoryItem item = JsonParser.gsonXml.fromXml(nodeRaw, MemoryMapConfigMemoryItem.class);
usageMap.put(item.getName(), item);
}
}
return usageMap;
}
Aggregations