diff --git a/firmware/development/perf_trace.cpp b/firmware/development/perf_trace.cpp index 67c24eab74..66c570e590 100644 --- a/firmware/development/perf_trace.cpp +++ b/firmware/development/perf_trace.cpp @@ -1,3 +1,9 @@ +/** + * @file perf_trace.cpp + * + * See JsonOutput.java in rusEfi console + */ + #include "efifeatures.h" #include "perf_trace.h" diff --git a/firmware/development/perf_trace.h b/firmware/development/perf_trace.h index 751cd94205..9893ad5881 100644 --- a/firmware/development/perf_trace.h +++ b/firmware/development/perf_trace.h @@ -10,7 +10,7 @@ // Defines different events we want to trace. These can be an interval (begin -> end), or an // instant. Instants can be global, or specific to one thread. You probably don't want to use // each element in PE more than once, as they should each indicate that a specific thing began, -// ended, or occured. +// ended, or occurred. enum class PE : uint8_t { // The tag below is consumed by PerfTraceTool.java // enum_start_tag diff --git a/java_console/models/src/com/rusefi/PerfTraceTool.java b/java_console/models/src/com/rusefi/PerfTraceTool.java index 0d81367115..0323f20b38 100644 --- a/java_console/models/src/com/rusefi/PerfTraceTool.java +++ b/java_console/models/src/com/rusefi/PerfTraceTool.java @@ -2,6 +2,7 @@ package com.rusefi; import com.rusefi.tracing.Entry; import com.rusefi.tracing.EnumNames; +import com.rusefi.tracing.JsonOutput; import java.io.*; import java.util.ArrayList; @@ -12,6 +13,10 @@ import java.util.List; * * This allows developers to only edit C/C++ header yet see proper names in chrome://tracing JSON file * + * This is not used in runtime while profiling actual firmward + * @see JsonOutput + * @see EnumNames + * * @see EnumNames * @see Entry * diff --git a/java_console/models/src/com/rusefi/tracing/Entry.java b/java_console/models/src/com/rusefi/tracing/Entry.java index d99dcd1204..bfb93a32d9 100644 --- a/java_console/models/src/com/rusefi/tracing/Entry.java +++ b/java_console/models/src/com/rusefi/tracing/Entry.java @@ -7,6 +7,8 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import static com.rusefi.tracing.EnumNames.TypeNames; + public class Entry { private final String name; private final Phase phase; @@ -78,7 +80,16 @@ public class Entry { double timestampSeconds = timestampNt / 1000000.0; minValue = Math.min(minValue, timestampNt); - Entry e = new Entry("t" + type, Phase.decode(phase), timestampSeconds); + String name; + if (type == 1) { + name = "ISR: " + thread; + } + else + { + name = TypeNames[type]; + } + + Entry e = new Entry(name, Phase.decode(phase), timestampSeconds); result.add(e); } diff --git a/java_console/models/src/com/rusefi/tracing/JsonOutput.java b/java_console/models/src/com/rusefi/tracing/JsonOutput.java index 15d8ac8e5f..1858a9b9ad 100644 --- a/java_console/models/src/com/rusefi/tracing/JsonOutput.java +++ b/java_console/models/src/com/rusefi/tracing/JsonOutput.java @@ -8,9 +8,35 @@ import java.util.List; * This class helps to write JSON files readable by chrome://tracing/ *

* See https://github.com/catapult-project/catapult/blob/master/tracing/README.md + * @see PerfTraceTool */ public class JsonOutput { + /** + * those are special entries that change display settings + * those set thread names and sort index based on those thread IDs + * (those thread IDs are interrupt numbers, and the name is the name of the interrupt handler) + */ + private static final String FORMATTING_SETTINGS + = "{\"name\":\"thread_name\",\"ph\":\"M\",\"tid\":18,\"pid\":0,\"args\":{\"name\":\"ADC\"}}," + + "{\"name\":\"thread_name\",\"ph\":\"M\",\"tid\":29,\"pid\":0,\"args\":{\"name\":\"TIM3\"}}," + + "{\"name\":\"thread_name\",\"ph\":\"M\",\"tid\":30,\"pid\":0,\"args\":{\"name\":\"TIM4\"}}," + + "{\"name\":\"thread_name\",\"ph\":\"M\",\"tid\":44,\"pid\":0,\"args\":{\"name\":\"TIM8/13\"}}," + + "{\"name\":\"thread_name\",\"ph\":\"M\",\"tid\":50,\"pid\":0,\"args\":{\"name\":\"TIM5\"}}," + + "{\"name\":\"thread_name\",\"ph\":\"M\",\"tid\":58,\"pid\":0,\"args\":{\"name\":\"DMA2s2\"}}," + + "{\"name\":\"thread_name\",\"ph\":\"M\",\"tid\":60,\"pid\":0,\"args\":{\"name\":\"DMA2s4\"}}," + + "{\"name\":\"thread_name\",\"ph\":\"M\",\"tid\":67,\"pid\":0,\"args\":{\"name\":\"USB\"}}," + + "{\"name\":\"thread_sort_index\",\"ph\":\"M\",\"tid\":18,\"pid\":0,\"args\":{\"sort_index\":4}}," + + "{\"name\":\"thread_sort_index\",\"ph\":\"M\",\"tid\":29,\"pid\":0,\"args\":{\"sort_index\":2}}," + + "{\"name\":\"thread_sort_index\",\"ph\":\"M\",\"tid\":30,\"pid\":0,\"args\":{\"sort_index\":5}}," + + "{\"name\":\"thread_sort_index\",\"ph\":\"M\",\"tid\":44,\"pid\":0,\"args\":{\"sort_index\":7}}," + + "{\"name\":\"thread_sort_index\",\"ph\":\"M\",\"tid\":50,\"pid\":0,\"args\":{\"sort_index\":3}}," + + "{\"name\":\"thread_sort_index\",\"ph\":\"M\",\"tid\":58,\"pid\":0,\"args\":{\"sort_index\":6}}," + + "{\"name\":\"thread_sort_index\",\"ph\":\"M\",\"tid\":60,\"pid\":0,\"args\":{\"sort_index\":8}}," + + "{\"name\":\"thread_sort_index\",\"ph\":\"M\",\"tid\":67,\"pid\":0,\"args\":{\"sort_index\":9}}" + ; + private static final String EOL = "\r\n"; + public static void main(String[] args) throws IOException { List testEntries = Arrays.asList( new Entry("hello", Phase.B, 0.1), @@ -25,16 +51,13 @@ public class JsonOutput { public static void writeToStream(List testEntries, OutputStream outputStream) throws IOException { Writer out = new OutputStreamWriter(outputStream); - out.write("{\"traceEvents\": [\n"); + out.write("{\"traceEvents\": [" + EOL); + + out.write(FORMATTING_SETTINGS + EOL); - boolean isFirst = true; for (Entry e : testEntries) { - if (isFirst) { - isFirst = false; - } else { - out.write(","); - } - out.write(e.toString() + "\r\n"); + out.write(","); + out.write(e.toString() + EOL); } out.write("]}"); diff --git a/java_console/ui/src/com/rusefi/Launcher.java b/java_console/ui/src/com/rusefi/Launcher.java index 6387211a47..f15db788ad 100644 --- a/java_console/ui/src/com/rusefi/Launcher.java +++ b/java_console/ui/src/com/rusefi/Launcher.java @@ -49,7 +49,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig; * @see EngineSnifferPanel */ public class Launcher { - public static final int CONSOLE_VERSION = 20191129; + public static final int CONSOLE_VERSION = 20191201; public static final String INI_FILE_PATH = System.getProperty("ini_file_path", ".."); public static final String INPUT_FILES_PATH = System.getProperty("input_files_path", ".."); public static final String TOOLS_PATH = System.getProperty("tools_path", ".");