Skip to content

Commit

Permalink
#89: Disabling simplification step for custom function names
Browse files Browse the repository at this point in the history
  • Loading branch information
bombomby committed Aug 12, 2019
1 parent ba2c7db commit 59831dd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 28 deletions.
14 changes: 9 additions & 5 deletions gui/Data/EventData.cs
Expand Up @@ -39,6 +39,8 @@ public abstract class Description
{
public abstract Object GetSharedKey();

public abstract bool HasShortName { get; }

private String name;
public String Name { get { return name; } }

Expand All @@ -49,12 +51,14 @@ public String FullName
set
{
fullName = value;
name = value;

String shortName = StripFunctionArguments(fullName);
if (shortName.Length != fullName.Length)
name = StripReturnValue(shortName);
else
name = fullName;
if (HasShortName)
{
String shortName = StripFunctionArguments(fullName);
if (shortName.Length != fullName.Length)
name = StripReturnValue(shortName);
}
}
}

Expand Down
31 changes: 12 additions & 19 deletions gui/Data/EventDescription.cs
Expand Up @@ -38,20 +38,6 @@ public override string ToString()

public class EventDescription : Description
{
private bool isSampling = false;
public bool IsSampling
{
get { return isSampling; }
set
{
if (isSampling != value)
{
ProfilerClient.Get().SendMessage(new TurnSamplingMessage(id, value));
isSampling = value;
}
}
}

private int id;
private Color forceColor;

Expand Down Expand Up @@ -105,8 +91,16 @@ public EventDescription(String name, int id = -1)
this.id = id;
}

const byte IS_SAMPLING_FLAG = 0x1;
public enum DescFlags : byte
{
NONE = 0,
IS_CUSTOM_NAME = 1 << 0,
}

public DescFlags Flags { get; private set; }

public override bool HasShortName { get { return (Flags & DescFlags.IS_CUSTOM_NAME) == 0; } }

public void SetOverrideColor(Color color)
{
Color = color;
Expand All @@ -116,8 +110,7 @@ public void SetOverrideColor(Color color)
static public EventDescription Read(BinaryReader reader, int id)
{
EventDescription desc = new EventDescription();
int nameLength = reader.ReadInt32();
desc.FullName = new String(reader.ReadChars(nameLength));
String fullName = Utils.ReadBinaryString(reader);
desc.id = id;

int fileLength = reader.ReadInt32();
Expand All @@ -132,8 +125,8 @@ static public EventDescription Read(BinaryReader reader, int id)

desc.Brush = new SolidColorBrush(desc.Color);
desc.Budget = reader.ReadSingle();
byte flags = reader.ReadByte();
desc.isSampling = (flags & IS_SAMPLING_FLAG) != 0;
desc.Flags = (DescFlags)reader.ReadByte();
desc.FullName = fullName;

return desc;
}
Expand Down
2 changes: 2 additions & 0 deletions gui/Data/SamplingFrame.cs
Expand Up @@ -64,6 +64,8 @@ public bool IsIgnore
}
}

public override bool HasShortName => true;

public static SamplingDescription UnresolvedDescription = new SamplingDescription() { FullName = "Unresolved", Address = 0, Path = FileLine.Empty };

public static SamplingDescription Create(BinaryReader reader, uint version)
Expand Down
11 changes: 10 additions & 1 deletion src/optick.h
Expand Up @@ -521,12 +521,18 @@ struct TagData
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct OPTICK_API EventDescription
{
enum Flags : uint8_t
{
IS_CUSTOM_NAME = 1 << 0,
};

const char* name;
const char* file;
uint32_t line;
uint32_t index;
uint32_t color;
uint32_t filter;
uint8_t flags;

static EventDescription* Create(const char* eventName, const char* fileName, const unsigned long fileLine, const unsigned long eventColor = Color::Null, const unsigned long filter = 0);
static EventDescription* CreateShared(const char* eventName, const char* fileName = nullptr, const unsigned long fileLine = 0, const unsigned long eventColor = Color::Null, const unsigned long filter = 0);
Expand Down Expand Up @@ -567,7 +573,10 @@ struct OPTICK_API Event
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OPTICK_INLINE Optick::EventDescription* CreateDescription(const char* functionName, const char* fileName, int fileLine, const char* eventName = nullptr, const ::Optick::Category::Type category = ::Optick::Category::None)
{
return ::Optick::EventDescription::Create(eventName != nullptr ? eventName : functionName, fileName, (unsigned long)fileLine, ::Optick::Category::GetColor(category), ::Optick::Category::GetMask(category));
::Optick::EventDescription* desc = ::Optick::EventDescription::Create(eventName != nullptr ? eventName : functionName, fileName, (unsigned long)fileLine, ::Optick::Category::GetColor(category), ::Optick::Category::GetMask(category));
if (eventName == nullptr)
desc->flags &= ~::Optick::EventDescription::IS_CUSTOM_NAME;
return desc;
}
OPTICK_INLINE Optick::EventDescription* CreateDescription(const char* functionName, const char* fileName, int fileLine, const ::Optick::Category::Type category)
{
Expand Down
5 changes: 2 additions & 3 deletions src/optick_core.cpp
Expand Up @@ -207,7 +207,7 @@ EventDescription* EventDescription::CreateShared(const char* eventName, const ch
return EventDescriptionBoard::Get().CreateSharedDescription(eventName, fileName, fileLine, eventColor, filter);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
EventDescription::EventDescription() : name(""), file(""), line(0), color(0)
EventDescription::EventDescription() : name(""), file(""), line(0), color(0), flags(IS_CUSTOM_NAME)
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -379,8 +379,7 @@ void Tag::Attach(const EventDescription& description, const char* val)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OutputDataStream & operator<<(OutputDataStream &stream, const EventDescription &ob)
{
byte flags = 0;
return stream << ob.name << ob.file << ob.line << ob.filter << ob.color << (float)0.0f << flags;
return stream << ob.name << ob.file << ob.line << ob.filter << ob.color << (float)0.0f << ob.flags;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OutputDataStream& operator<<(OutputDataStream& stream, const EventTime& ob)
Expand Down

0 comments on commit 59831dd

Please sign in to comment.