Search in sources :

Example 6 with MemoryMapConfigMemoryItem

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;
}
Also used : MemoryMapConfigMemoryItem(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem)

Example 7 with MemoryMapConfigMemoryItem

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;
}
Also used : MemoryMapConfigMemoryItem(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem)

Example 8 with MemoryMapConfigMemoryItem

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;
}
Also used : ChartUtil(hudson.util.ChartUtil) MemoryMapConfigMemoryItem(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem) MemoryMapConfigMemory(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory)

Example 9 with MemoryMapConfigMemoryItem

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;
}
Also used : MemoryMapConfigMemoryItem(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem)

Example 10 with MemoryMapConfigMemoryItem

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;
}
Also used : MemoryMapConfigMemoryItem(net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem) HashMap(java.util.HashMap) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) File(java.io.File)

Aggregations

MemoryMapConfigMemoryItem (net.praqma.jenkins.memorymap.result.MemoryMapConfigMemoryItem)14 Matcher (java.util.regex.Matcher)5 MemoryMapConfigMemory (net.praqma.jenkins.memorymap.result.MemoryMapConfigMemory)4 File (java.io.File)3 HashMap (java.util.HashMap)3 Pattern (java.util.regex.Pattern)2 AbstractMemoryMapParser (net.praqma.jenkins.memorymap.parser.AbstractMemoryMapParser)2 HexifiableString (net.praqma.jenkins.memorymap.util.HexUtils.HexifiableString)2 MemoryMapMemorySelectionError (net.praqma.jenkins.memorymap.util.MemoryMapMemorySelectionError)2 Document (org.w3c.dom.Document)2 NodeList (org.w3c.dom.NodeList)2 AbortException (hudson.AbortException)1 FreeStyleBuild (hudson.model.FreeStyleBuild)1 ChartUtil (hudson.util.ChartUtil)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 MemoryMapGraphConfiguration (net.praqma.jenkins.memorymap.graph.MemoryMapGraphConfiguration)1 TexasInstrumentsMemoryMapParser (net.praqma.jenkins.memorymap.parser.ti.TexasInstrumentsMemoryMapParser)1 HexUtils (net.praqma.jenkins.memorymap.util.HexUtils)1