Add the opc performance test async and sync in same senario

This commit is contained in:
luoyan35714
2014-12-12 10:34:25 +08:00
parent 32938d33c0
commit 630d186fae
9 changed files with 2051 additions and 89 deletions
@@ -60,10 +60,12 @@ public class SyncPerfTest {
public void writeComplete(int arg0, int arg1, int arg2,
ResultSet<Integer> arg3) {
}
public void readComplete(int arg0, int arg1, int arg2, int arg3,
KeyedResultSet<Integer, ValueData> arg4) {
}
public void dataChange(int arg0, int arg1, int arg2, int arg3,
KeyedResultSet<Integer, ValueData> items) {
for (KeyedResult<Integer, ValueData> item : items) {
@@ -71,6 +73,7 @@ public class SyncPerfTest {
+ item.getValue());
}
}
public void cancelComplete(int arg0, int arg1) {
}
@@ -19,10 +19,25 @@ import org.openscada.opc.lib.da.Item;
import org.openscada.opc.lib.da.Server;
public class AsyncMultiThreadTest {
private static Logger LOGGER = Logger.getLogger(AsyncMultiThreadTest.class);
private static final int count = 1;
public synchronized static void start(long in) {
if (start == 0)
start = in;
}
public synchronized static void end(long in) {
end = in;
LOGGER.info("Asynch read total used[" + (end - start) + "] s");
}
private static long start;
private static long end;
private static final int count = 5;
public static void main(String[] args) throws Exception {
for (int i = 1; i <= count; i++) {
new Thread(new AsyncMulti(i)).start();
}
@@ -33,7 +48,7 @@ class AsyncMulti implements Runnable {
private static Logger LOGGER = Logger.getLogger(AsyncMulti.class);
private static final int NUMBER = 10000;
private static final int NUMBER = 4000;
private int count_number;
private static long start;
@@ -65,6 +80,7 @@ class AsyncMulti implements Runnable {
}
read = System.currentTimeMillis();
AsyncMultiThreadTest.start(read);
group.attach(new IOPCDataCallback() {
public void writeComplete(int arg0, int arg1, int arg2,
@@ -84,8 +100,10 @@ class AsyncMulti implements Runnable {
if (i == NUMBER) {
end = System.currentTimeMillis();
LOGGER.info("Total Use[" + (end - start)
+ "] and Async Read[" + (end - read) + "]");
// LOGGER.info("[" + count_number + "]Total Use["
// + (end - start) + "] and Async Read["
// + (end - read) + "]");
AsyncMultiThreadTest.end(end);
}
}
@@ -109,6 +127,7 @@ class AsyncMulti implements Runnable {
group.remove();
server.disconnect();
} catch (Exception e) {
e.printStackTrace();
}
@@ -2,7 +2,6 @@ package com.freud.opc.utgard.perf;
import static com.freud.opc.utgard.perf.config.ConfigReader.config;
import java.text.MessageFormat;
import java.util.Date;
import org.apache.log4j.Logger;
@@ -11,9 +10,25 @@ import org.openscada.opc.lib.da.Item;
import org.openscada.opc.lib.da.Server;
public class SyncMultiThreadTest {
private static Logger LOGGER = Logger.getLogger(SyncMultiThreadTest.class);
public synchronized static void start(long in) {
if (start == 0)
start = in;
}
public synchronized static void end(long in) {
end = in;
LOGGER.info("Asynch read total used[" + (end - start) + "] s");
}
private static long start;
private static long end;
private static final int count = 100;
public static void main(String[] args) throws Exception {
for (int i = 1; i <= 20; i++) {
for (int i = 1; i <= count; i++) {
new Thread(new TestMultiple(i)).start();
}
}
@@ -23,7 +38,7 @@ class TestMultiple implements Runnable {
private static Logger LOGGER = Logger.getLogger(TestMultiple.class);
private static final int NUMBER = 20000;
private static final int NUMBER = 4000;
private int count_number;
@@ -45,8 +60,8 @@ class TestMultiple implements Runnable {
int limit = count_number * NUMBER;
LOGGER.info("[" + limit + "W:]" + "Step-" + limit + "W:");
LOGGER.info("[" + limit + "W:]" + "startDate[" + new Date()
LOGGER.info("[" + limit + ":]" + "Step-" + limit + ":");
LOGGER.info("[" + limit + ":]" + "startDate[" + new Date()
+ "],CurrentMillis:" + start);
Server server = new Server(config(), null);
@@ -73,16 +88,16 @@ class TestMultiple implements Runnable {
long read = System.currentTimeMillis();
LOGGER.info("[" + limit + "W:]" + "Start Read[" + new Date()
+ "],CurrentMillis:" + read);
SyncMultiThreadTest.start(read);
group.read(true, items);
long end = System.currentTimeMillis();
LOGGER.info("[" + limit + "W:]" + "End Read[" + new Date()
+ "],CurrentMillis:" + end);
LOGGER.info(MessageFormat.format("[" + limit + "W:]"
+ "Total[{0}], CreateItem[{1}], Read[{2}]", end - start,
createEnd - createStart, end - read));
// LOGGER.info("[" + limit + "W:]" + "End Read[" + new Date()
// + "],CurrentMillis:" + end);
SyncMultiThreadTest.end(end);
// LOGGER.info(MessageFormat.format("[" + limit + "W:]"
// + "Total[{0}], CreateItem[{1}], Read[{2}]", end - start,
// createEnd - createStart, end - read));
group.remove();
server.dispose();