maybe helping simulator performance
This commit is contained in:
parent
8ba703da6b
commit
12f72e7d82
|
@ -6,6 +6,7 @@ import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 3/18/14
|
* 3/18/14
|
||||||
|
@ -46,30 +47,41 @@ public class ExecHelper {
|
||||||
thread.setDaemon(true);
|
thread.setDaemon(true);
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
||||||
readAndPrint("from console: ", input);
|
String prefix = "from console: ";
|
||||||
|
Consumer<String> PRINT_AND_LOG = string -> {
|
||||||
|
// looks like this is a performance issue since so many lines are printed? looks like it's helping to not write this?
|
||||||
|
|
||||||
|
// System.out.println(prefix + string);
|
||||||
|
// FileLog.SIMULATOR_CONSOLE.logLine(string);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
readAndPrint(PRINT_AND_LOG, input);
|
||||||
input.close();
|
input.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void readAndPrint(String prefix, BufferedReader input) throws IOException {
|
private static void readAndPrint(Consumer<String> consumer, BufferedReader input) throws IOException {
|
||||||
String line;
|
String line;
|
||||||
while ((line = input.readLine()) != null) {
|
while ((line = input.readLine()) != null) {
|
||||||
System.out.println(prefix + line);
|
consumer.accept(line);
|
||||||
FileLog.SIMULATOR_CONSOLE.logLine(line);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Runnable createErrorStreamEcho(final Process process) {
|
private static Runnable createErrorStreamEcho(final Process process) {
|
||||||
return new Runnable() {
|
return () -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
BufferedReader err =
|
BufferedReader err =
|
||||||
new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
new BufferedReader(new InputStreamReader(process.getErrorStream()));
|
||||||
try {
|
try {
|
||||||
readAndPrint("from err: ", err);
|
String prefix = "from console: ";
|
||||||
|
Consumer<String> PRINT_AND_LOG = string -> {
|
||||||
|
System.out.println(prefix + string);
|
||||||
|
FileLog.SIMULATOR_CONSOLE.logLine(string);
|
||||||
|
};
|
||||||
|
|
||||||
|
readAndPrint(PRINT_AND_LOG, err);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class IncomingDataBuffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addData(byte[] freshData) {
|
public void addData(byte[] freshData) {
|
||||||
logger.info(freshData.length + " byte(s) arrived");
|
logger.info("IncomingDataBuffer: " + freshData.length + " byte(s) arrived");
|
||||||
synchronized (cbb) {
|
synchronized (cbb) {
|
||||||
if (cbb.size() - cbb.length() < freshData.length) {
|
if (cbb.size() - cbb.length() < freshData.length) {
|
||||||
logger.error("IncomingDataBuffer: buffer overflow not expected");
|
logger.error("IncomingDataBuffer: buffer overflow not expected");
|
||||||
|
|
|
@ -45,7 +45,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
* @see EngineSnifferPanel
|
* @see EngineSnifferPanel
|
||||||
*/
|
*/
|
||||||
public class Launcher {
|
public class Launcher {
|
||||||
public static final int CONSOLE_VERSION = 20181012;
|
public static final int CONSOLE_VERSION = 20181013;
|
||||||
public static final boolean SHOW_STIMULATOR = false;
|
public static final boolean SHOW_STIMULATOR = false;
|
||||||
private static final String TAB_INDEX = "main_tab";
|
private static final String TAB_INDEX = "main_tab";
|
||||||
protected static final String PORT_KEY = "port";
|
protected static final String PORT_KEY = "port";
|
||||||
|
|
Loading…
Reference in New Issue