<commit_before>package org.jspringbot.jmeter.cmdtools.plugin;

import java.util.Collection;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.Format;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.table.TableCellRenderer;
import kg.apc.charting.GraphPanelChart;
import kg.apc.jmeter.graphs.AbstractGraphPanelVisualizer;
import kg.apc.jmeter.vizualizers.JSettingsPanel;
import kg.apc.jmeter.vizualizers.SynthesisReportGui;
import org.apache.jmeter.gui.util.HeaderAsPropertyRenderer;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.save.CSVSaveService;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.visualizers.SamplingStatCalculator;
import org.apache.jmeter.visualizers.StatVisualizer;
import org.apache.jorphan.gui.NumberRenderer;
import org.apache.jorphan.gui.ObjectTableModel;
import org.apache.jorphan.gui.RateRenderer;
import org.apache.jorphan.gui.RendererUtils;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.jorphan.reflect.Functor;
import org.apache.log.Logger;

/**
 * OMG, I had to copy full contents of StatVisualizer just to make its data
 * visible to JMeterPluginsCMD. This class is just invisible in menu;
 *
 * @see StatVisualizer
 */
public class CustomAggregateReport extends AbstractGraphPanelVisualizer {

    private Collection<String> emptyCollection = new ArrayList<String>();
    private static final long serialVersionUID = 241L;
    private static final Logger log = LoggingManager.getLoggerForClass();
    private static final String USE_GROUP_NAME = "useGroupName";
    private static final String SAVE_HEADERS = "saveHeaders";
    private static final String[] COLUMNS = {
        "label",
        "count",
        "average",
        "median",
        "90%",
            "95%",
            "99%",
            "min",
        "max",
        "error%",
        "rate",
        "bandwidth",
        "stddev",};
    private final String TOTAL_ROW_LABEL = JMeterUtils.getResString("aggregate_report_total_label");
    private JTable myJTable;
    private JScrollPane myScrollPane;
    private final JButton saveTable =
            new JButton(JMeterUtils.getResString("aggregate_graph_save_table"));
    private final JCheckBox saveHeaders = // should header be saved with the data?
            new JCheckBox(JMeterUtils.getResString("aggregate_graph_save_table_header"), true);
    private final JCheckBox useGroupName =
            new JCheckBox(JMeterUtils.getResString("aggregate_graph_use_group_name"));
    private transient ObjectTableModel statModel;
    private final Map<String, SamplingStatCalculator> tableRows =
            new ConcurrentHashMap<String, SamplingStatCalculator>();

    public CustomAggregateReport() {
        super();
        statModel = new ObjectTableModel(COLUMNS,
                SamplingStatCalculator.class,
                new Functor[]{
                    new Functor("getLabel"),
                    new Functor("getCount"),
                    new Functor("getMeanAsNumber"),
                    new Functor("getMedian"),
                    new Functor("getPercentPoint",new Object[]{new Float(.900)}),
                        new Functor("getPercentPoint",new Object[]{new Float(.950)}),
                        new Functor("getPercentPoint",new Object[]{new Float(.990)}),
                    new Functor("getMin"),
                    new Functor("getMax"),
                    new Functor("getErrorPercentage"),
                    new Functor("getRate"),
                    new Functor("getKBPerSecond"),
                    new Functor("getStandardDeviation"),},
                new Functor[]{null, null, null, null, null, null, null, null, null, null, null},
                new Class[]{String.class, Long.class, Long.class, Long.class, Long.class,
                    Long.class, Long.class, String.class, String.class, String.class, String.class});
        clearData();
        init();
    }

    //do not insert this vizualiser in any JMeter menu
    @Override
    public Collection<String> getMenuCategories() {
        return emptyCollection;
    }
    // Column renderers
    private static final TableCellRenderer[] RENDERERS =
        new TableCellRenderer[]{
            null, // Label
            null, // count
            null, // Mean
            null, // median
            null, // 90%
                null, // 95%
                null, // 99%

            null, // Min
            null, // Max
            new NumberRenderer("#0.00%"), // Error %age
            new RateRenderer("#.0"), // Throughput
            new NumberRenderer("#.0"), // pageSize
            new NumberRenderer("#0.00"), // Std Dev.
        };

    // Column formats
    static final Format[] FORMATS =
        new Format[]{
            null, // Label
            null, // count
            null, // Mean
            null, // median
            null, // 90%
                null, // 95%
                null, // 99%
                null, // Min
            null, // Max
            new DecimalFormat("#0.00%"), // Error %age
            new DecimalFormat("#.0"), // Throughput
            new DecimalFormat("#.0"), // pageSize
            new DecimalFormat("#0.00"), // Std Dev.
        };

    @Override
    public String getLabelResource() {
        return "custom_aggregate_report";
    }

    @Override
    public void add(SampleResult res) {
        if (!isSampleIncluded(res)) {
            return;<commit_msg>added decimal places to rate and kb/sec<commit_after>package org.jspringbot.jmeter.cmdtools.plugin;

import java.util.Collection;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DecimalFormat;
import java.text.Format;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.table.TableCellRenderer;
import kg.apc.charting.GraphPanelChart;
import kg.apc.jmeter.graphs.AbstractGraphPanelVisualizer;
import kg.apc.jmeter.vizualizers.JSettingsPanel;
import kg.apc.jmeter.vizualizers.SynthesisReportGui;
import org.apache.jmeter.gui.util.HeaderAsPropertyRenderer;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.save.CSVSaveService;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jmeter.visualizers.SamplingStatCalculator;
import org.apache.jmeter.visualizers.StatVisualizer;
import org.apache.jorphan.gui.NumberRenderer;
import org.apache.jorphan.gui.ObjectTableModel;
import org.apache.jorphan.gui.RateRenderer;
import org.apache.jorphan.gui.RendererUtils;
import org.apache.jorphan.logging.LoggingManager;
import org.apache.jorphan.reflect.Functor;
import org.apache.log.Logger;

/**
 * OMG, I had to copy full contents of StatVisualizer just to make its data
 * visible to JMeterPluginsCMD. This class is just invisible in menu;
 *
 * @see StatVisualizer
 */
public class CustomAggregateReport extends AbstractGraphPanelVisualizer {

    private Collection<String> emptyCollection = new ArrayList<String>();
    private static final long serialVersionUID = 241L;
    private static final Logger log = LoggingManager.getLoggerForClass();
    private static final String USE_GROUP_NAME = "useGroupName";
    private static final String SAVE_HEADERS = "saveHeaders";
    private static final String[] COLUMNS = {
        "label",
        "count",
        "average",
        "median",
        "90%",
        "95%",
        "99%",
        "min",
        "max",
        "error%",
        "rate",
        "KB/sec",
        "stddev",};
    private final String TOTAL_ROW_LABEL = JMeterUtils.getResString("aggregate_report_total_label");
    private JTable myJTable;
    private JScrollPane myScrollPane;
    private final JButton saveTable =
            new JButton(JMeterUtils.getResString("aggregate_graph_save_table"));
    private final JCheckBox saveHeaders = // should header be saved with the data?
            new JCheckBox(JMeterUtils.getResString("aggregate_graph_save_table_header"), true);
    private final JCheckBox useGroupName =
            new JCheckBox(JMeterUtils.getResString("aggregate_graph_use_group_name"));
    private transient ObjectTableModel statModel;
    private final Map<String, SamplingStatCalculator> tableRows =
            new ConcurrentHashMap<String, SamplingStatCalculator>();

    public CustomAggregateReport() {
        super();
        statModel = new ObjectTableModel(COLUMNS,
                SamplingStatCalculator.class,
                new Functor[]{
                    new Functor("getLabel"),
                    new Functor("getCount"),
                    new Functor("getMeanAsNumber"),
                    new Functor("getMedian"),
                    new Functor("getPercentPoint",new Object[]{new Float(.900)}),
                    new Functor("getPercentPoint",new Object[]{new Float(.950)}),
                    new Functor("getPercentPoint",new Object[]{new Float(.990)}),
                    new Functor("getMin"),
                    new Functor("getMax"),
                    new Functor("getErrorPercentage"),
                    new Functor("getRate"),
                    new Functor("getKBPerSecond"),
                    new Functor("getStandardDeviation"),},
                new Functor[]{null, null, null, null, null, null, null, null, null, null, null},
                new Class[]{String.class, Long.class, Long.class, Long.class, Long.class,
                    Long.class, Long.class, String.class, String.class, String.class, String.class});
        clearData();
        init();
    }

    //do not insert this vizualiser in any JMeter menu
    @Override
    public Collection<String> getMenuCategories() {
        return emptyCollection;
    }
    // Column renderers
    private static final TableCellRenderer[] RENDERERS =
        new TableCellRenderer[]{
            null, // Label
            null, // count
            null, // Mean
            null, // median
            null, // 90%
            null, // 95%
            null, // 99%
            null, // Min
            null, // Max
            new NumberRenderer("#0.00%"), // Error %age
            new RateRenderer("#.00"), // Throughput
            new NumberRenderer("#.00"), // pageSize
            new NumberRenderer("#0.00"), // Std Dev.
        };

    // Column formats
    static final Format[] FORMATS =
        new Format[]{
            null, // Label
            null, // count
            null, // Mean
            null, // median
            null, // 90%
            null, // 95%
            null, // 99%
            null, // Min
            null, // Max
            new DecimalFormat("#0.00%"), // Error %age
            new DecimalFormat("#.0"), // Throughput
            new DecimalFormat("#.0"), // pageSize
            new DecimalFormat("#0.00"), // Std Dev.
        };

    @Override
    public String getLabelResource() {
        return "custom_aggregate_report";
    }

    @Override
    public void add(SampleResult res) {
        if (!isSampleIncluded(res)) {
            return;
{'fraction_non_alphanumeric': 0.10801992100291946, 'fraction_numerical': 0.008071440838055985, 'mean_word_length': 2.4235743680188127, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3526145', 'n_tokens_mistral': 3320, 'n_tokens_neox': 3140, 'n_words': 753}