maybe helping simulator performance

This commit is contained in:
rusefi 2018-10-13 09:25:11 -04:00
parent 8ba703da6b
commit 12f72e7d82
3 changed files with 28 additions and 16 deletions

View File

@ -6,6 +6,7 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.function.Consumer;
/**
* 3/18/14
@ -46,29 +47,40 @@ public class ExecHelper {
thread.setDaemon(true);
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();
}
private static void readAndPrint(String prefix, BufferedReader input) throws IOException {
private static void readAndPrint(Consumer<String> consumer, BufferedReader input) throws IOException {
String line;
while ((line = input.readLine()) != null) {
System.out.println(prefix + line);
FileLog.SIMULATOR_CONSOLE.logLine(line);
consumer.accept(line);
}
}
private static Runnable createErrorStreamEcho(final Process process) {
return new Runnable() {
@Override
public void run() {
BufferedReader err =
new BufferedReader(new InputStreamReader(process.getErrorStream()));
try {
readAndPrint("from err: ", err);
} catch (IOException e) {
throw new IllegalStateException(e);
}
return () -> {
BufferedReader err =
new BufferedReader(new InputStreamReader(process.getErrorStream()));
try {
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) {
throw new IllegalStateException(e);
}
};
}

View File

@ -29,7 +29,7 @@ public class IncomingDataBuffer {
}
public void addData(byte[] freshData) {
logger.info(freshData.length + " byte(s) arrived");
logger.info("IncomingDataBuffer: " + freshData.length + " byte(s) arrived");
synchronized (cbb) {
if (cbb.size() - cbb.length() < freshData.length) {
logger.error("IncomingDataBuffer: buffer overflow not expected");

View File

@ -45,7 +45,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see EngineSnifferPanel
*/
public class Launcher {
public static final int CONSOLE_VERSION = 20181012;
public static final int CONSOLE_VERSION = 20181013;
public static final boolean SHOW_STIMULATOR = false;
private static final String TAB_INDEX = "main_tab";
protected static final String PORT_KEY = "port";