Search in sources :

Example 41 with ConcurrentSkipListMap

use of java.util.concurrent.ConcurrentSkipListMap in project jmeter-plugins by undera.

the class GraphModelToCsvExporterTest method createTestModel.

private ConcurrentSkipListMap<String, AbstractGraphRow> createTestModel() {
    ConcurrentSkipListMap<String, AbstractGraphRow> testModel = new ConcurrentSkipListMap<>();
    Calendar now = Calendar.getInstance();
    now.set(Calendar.HOUR_OF_DAY, 10);
    now.set(Calendar.MINUTE, 30);
    now.set(Calendar.SECOND, 0);
    now.set(Calendar.MILLISECOND, 500);
    GraphRowAverages row1 = new GraphRowAverages();
    GraphRowAverages row2 = new GraphRowAverages();
    GraphRowAverages row3 = new GraphRowAverages();
    testModel.put("row1", row1);
    testModel.put("row2", row2);
    testModel.put("row3", row3);
    row1.add(now.getTimeInMillis(), 10);
    row2.add(now.getTimeInMillis(), 20);
    now.set(Calendar.SECOND, 10);
    row1.add(now.getTimeInMillis(), 20);
    row2.add(now.getTimeInMillis(), 30);
    now.set(Calendar.SECOND, 25);
    row3.add(now.getTimeInMillis(), 50);
    return testModel;
}
Also used : GraphRowAverages(kg.apc.charting.rows.GraphRowAverages) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) Calendar(java.util.Calendar)

Example 42 with ConcurrentSkipListMap

use of java.util.concurrent.ConcurrentSkipListMap in project jmeter-plugins by undera.

the class GraphPanelChartTest method testPaintComponent.

/**
 * Test of paintComponent method, of class GraphPanelChart.
 */
@Test
public void testPaintComponent() {
    System.out.println("paintComponent");
    Graphics g = new TestGraphics();
    GraphPanelChart instance = new GraphPanelChart();
    instance.setSize(500, 500);
    instance.getChartSettings().setDrawFinalZeroingLines(true);
    instance.getChartSettings().setDrawCurrentX(true);
    instance.getChartSettings().setExpendRows(true);
    final ConcurrentSkipListMap<String, AbstractGraphRow> rows = new ConcurrentSkipListMap<String, AbstractGraphRow>();
    instance.setRows(rows);
    final GraphRowAverages row1 = new GraphRowAverages();
    row1.setDrawThickLines(true);
    row1.setDrawLine(true);
    row1.setDrawBar(true);
    row1.setDrawValueLabel(true);
    row1.setMarkerSize(AbstractGraphRow.MARKER_SIZE_BIG);
    rows.put("test 1", row1);
    row1.add(System.currentTimeMillis(), 20);
    instance.paintComponent(g);
    row1.add(System.currentTimeMillis(), 540);
    instance.setxAxisLabelRenderer(new DateTimeRenderer("HH:mm:ss"));
    instance.paintComponent(g);
    row1.add(System.currentTimeMillis(), 8530);
    instance.paintComponent(g);
}
Also used : TestGraphics(kg.apc.emulators.TestGraphics) GraphRowAverages(kg.apc.charting.rows.GraphRowAverages) TestGraphics(kg.apc.emulators.TestGraphics) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap)

Example 43 with ConcurrentSkipListMap

use of java.util.concurrent.ConcurrentSkipListMap in project jmeter-plugins by undera.

the class GraphPanelChartTest method testSaveGraphToCSV.

/**
 * Test of saveGraphToCSV method, of class GraphPanelChart.
 */
@Test
public void testSaveGraphToCSV() throws Exception {
    System.out.println("saveGraphToCSV");
    File file = File.createTempFile("test", ".csv");
    GraphPanelChart instance = new GraphPanelChart();
    final ConcurrentSkipListMap<String, AbstractGraphRow> rows = new ConcurrentSkipListMap<String, AbstractGraphRow>();
    instance.setRows(rows);
    instance.saveGraphToCSV(file);
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) File(java.io.File)

Example 44 with ConcurrentSkipListMap

use of java.util.concurrent.ConcurrentSkipListMap in project jmeter-plugins by undera.

the class AbstractGraphPanelVisualizerTest method testGetNewRow_9args.

/**
 * Test of getNewRow method, of class AbstractGraphPanelVisualizer.
 */
@Test
public void testGetNewRow_9args() {
    System.out.println("getNewRow");
    ConcurrentSkipListMap<String, AbstractGraphRow> model = new ConcurrentSkipListMap<String, AbstractGraphRow>();
    int rowType = 0;
    String label = "";
    int markerSize = 0;
    boolean isBarRow = false;
    boolean displayLabel = false;
    boolean thickLines = false;
    boolean showInLegend = false;
    boolean canCompose = false;
    AbstractGraphPanelVisualizer instance = new AbstractGraphPanelVisualizerImpl();
    AbstractGraphRow result = instance.getNewRow(model, rowType, label, markerSize, isBarRow, displayLabel, thickLines, showInLegend, canCompose);
    assertNotNull(result);
}
Also used : AbstractGraphRow(kg.apc.charting.AbstractGraphRow) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap)

Example 45 with ConcurrentSkipListMap

use of java.util.concurrent.ConcurrentSkipListMap in project accumulo by apache.

the class NativeMapPerformanceTest method runPerformanceTest.

static void runPerformanceTest(int numRows, int numCols, int numLookups, String mapType) {
    SortedMap<Key, Value> tm = null;
    NativeMap nm = null;
    if (mapType.equals("SKIP_LIST"))
        tm = new ConcurrentSkipListMap<>();
    else if (mapType.equals("TREE_MAP"))
        tm = Collections.synchronizedSortedMap(new TreeMap<Key, Value>());
    else if (mapType.equals("NATIVE_MAP"))
        nm = new NativeMap();
    else
        throw new IllegalArgumentException(" map type must be SKIP_LIST, TREE_MAP, or NATIVE_MAP");
    Random rand = new Random(19);
    // puts
    long tps = System.currentTimeMillis();
    if (nm != null) {
        for (int i = 0; i < numRows; i++) {
            int row = rand.nextInt(1000000000);
            Mutation m = newMutation(row);
            for (int j = 0; j < numCols; j++) {
                int col = rand.nextInt(1000000);
                Value val = new Value("test".getBytes(UTF_8));
                pc(m, col, val);
            }
            nm.mutate(m, i);
        }
    } else {
        for (int i = 0; i < numRows; i++) {
            int row = rand.nextInt(1000000000);
            for (int j = 0; j < numCols; j++) {
                int col = rand.nextInt(1000000);
                Key key = newKey(row, col);
                Value val = new Value("test".getBytes(UTF_8));
                tm.put(key, val);
            }
        }
    }
    long tpe = System.currentTimeMillis();
    // Iteration
    Iterator<Entry<Key, Value>> iter;
    if (nm != null) {
        iter = nm.iterator();
    } else {
        iter = tm.entrySet().iterator();
    }
    long tis = System.currentTimeMillis();
    while (iter.hasNext()) {
        iter.next();
    }
    long tie = System.currentTimeMillis();
    rand = new Random(19);
    int[] rowsToLookup = new int[numLookups];
    int[] colsToLookup = new int[numLookups];
    for (int i = 0; i < Math.min(numLookups, numRows); i++) {
        int row = rand.nextInt(1000000000);
        int col = -1;
        for (int j = 0; j < numCols; j++) {
            col = rand.nextInt(1000000);
        }
        rowsToLookup[i] = row;
        colsToLookup[i] = col;
    }
    // get
    long tgs = System.currentTimeMillis();
    if (nm != null) {
        for (int i = 0; i < numLookups; i++) {
            Key key = newKey(rowsToLookup[i], colsToLookup[i]);
            if (nm.get(key) == null) {
                throw new RuntimeException("Did not find " + rowsToLookup[i] + " " + colsToLookup[i] + " " + i);
            }
        }
    } else {
        for (int i = 0; i < numLookups; i++) {
            Key key = newKey(rowsToLookup[i], colsToLookup[i]);
            if (tm.get(key) == null) {
                throw new RuntimeException("Did not find " + rowsToLookup[i] + " " + colsToLookup[i] + " " + i);
            }
        }
    }
    long tge = System.currentTimeMillis();
    long memUsed = 0;
    if (nm != null) {
        memUsed = nm.getMemoryUsed();
    }
    int size = (nm == null ? tm.size() : nm.size());
    // delete
    long tds = System.currentTimeMillis();
    if (nm != null)
        nm.delete();
    long tde = System.currentTimeMillis();
    if (tm != null)
        tm.clear();
    System.gc();
    System.gc();
    System.gc();
    System.gc();
    sleepUninterruptibly(3, TimeUnit.SECONDS);
    System.out.printf("mapType:%10s   put rate:%,6.2f  scan rate:%,6.2f  get rate:%,6.2f  delete time : %6.2f  mem : %,d%n", "" + mapType, (numRows * numCols) / ((tpe - tps) / 1000.0), (size) / ((tie - tis) / 1000.0), numLookups / ((tge - tgs) / 1000.0), (tde - tds) / 1000.0, memUsed);
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) TreeMap(java.util.TreeMap) Entry(java.util.Map.Entry) Random(java.util.Random) Value(org.apache.accumulo.core.data.Value) Mutation(org.apache.accumulo.core.data.Mutation) NativeMap(org.apache.accumulo.tserver.NativeMap) Key(org.apache.accumulo.core.data.Key)

Aggregations

ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)183 Test (org.junit.Test)66 PollStatus (org.opennms.netmgt.poller.PollStatus)32 MonitoredService (org.opennms.netmgt.poller.MonitoredService)31 Map (java.util.Map)30 ServiceMonitor (org.opennms.netmgt.poller.ServiceMonitor)25 MqttDeviceTwin (com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceTwin)23 HashMap (java.util.HashMap)21 DeviceTwinMessage (com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceTwinMessage)17 NavigableMap (java.util.NavigableMap)14 Set (java.util.Set)12 Iterator (java.util.Iterator)11 NavigableSet (java.util.NavigableSet)11 MockMonitoredService (org.opennms.netmgt.poller.mock.MockMonitoredService)11 IOException (java.io.IOException)10 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)10 ArrayList (java.util.ArrayList)9 BitSet (java.util.BitSet)9 DeviceOperations (com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations)8 JUnitHttpServer (org.opennms.core.test.http.annotations.JUnitHttpServer)8