perf trace progress but things still do not look right

This commit is contained in:
rusefi 2019-12-01 20:31:18 -05:00
parent 3b352f6a3a
commit c39eb0c08d
6 changed files with 56 additions and 11 deletions

View File

@ -1,3 +1,9 @@
/**
* @file perf_trace.cpp
*
* See JsonOutput.java in rusEfi console
*/
#include "efifeatures.h"
#include "perf_trace.h"

View File

@ -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

View File

@ -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
*

View File

@ -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);
}

View File

@ -8,9 +8,35 @@ import java.util.List;
* This class helps to write JSON files readable by chrome://tracing/
* <p>
* 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<Entry> testEntries = Arrays.asList(
new Entry("hello", Phase.B, 0.1),
@ -25,16 +51,13 @@ public class JsonOutput {
public static void writeToStream(List<Entry> 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("]}");

View File

@ -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", ".");