Skip to content

Commit 6f0a51b

Browse files
committed
Fix VGR-9003 benchmark unity helper collisions
1 parent d337657 commit 6f0a51b

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

Plugins/Vergil/Source/VergilAutomation/Private/Tests/VergilBenchmarkTests.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace
5353
FVergilLargeGraphBenchmarkPhaseResult Apply;
5454
};
5555

56-
FVergilLargeGraphBenchmarkScenario MakeScenario(
56+
FVergilLargeGraphBenchmarkScenario MakeBenchmarkScenario(
5757
const TCHAR* Name,
5858
const int32 SegmentCount,
5959
const int32 CommentStride,
@@ -69,7 +69,7 @@ namespace
6969
return Scenario;
7070
}
7171

72-
TStrongObjectPtr<UBlueprint> MakeTransientBlueprint(UClass* ParentClass = nullptr)
72+
TStrongObjectPtr<UBlueprint> MakeBenchmarkTransientBlueprint(UClass* ParentClass = nullptr)
7373
{
7474
if (ParentClass == nullptr)
7575
{
@@ -90,7 +90,7 @@ namespace
9090
TEXT("VergilAutomation")));
9191
}
9292

93-
FVergilVariableDefinition MakeBoolVariable(const FName Name, const FString& DefaultValue)
93+
FVergilVariableDefinition MakeBenchmarkBoolVariable(const FName Name, const FString& DefaultValue)
9494
{
9595
FVergilVariableDefinition Variable;
9696
Variable.Name = Name;
@@ -99,7 +99,7 @@ namespace
9999
return Variable;
100100
}
101101

102-
FVergilGraphNode MakeNode(const EVergilNodeKind Kind, const FName Descriptor, const FVector2D Position)
102+
FVergilGraphNode MakeBenchmarkNode(const EVergilNodeKind Kind, const FName Descriptor, const FVector2D Position)
103103
{
104104
FVergilGraphNode Node;
105105
Node.Id = FGuid::NewGuid();
@@ -109,7 +109,7 @@ namespace
109109
return Node;
110110
}
111111

112-
FVergilGraphPin MakePin(
112+
FVergilGraphPin MakeBenchmarkPin(
113113
const FName Name,
114114
const EVergilPinDirection Direction,
115115
const bool bIsExec = false,
@@ -124,7 +124,7 @@ namespace
124124
return Pin;
125125
}
126126

127-
FVergilGraphEdge MakeEdge(
127+
FVergilGraphEdge MakeBenchmarkEdge(
128128
const FVergilGraphNode& SourceNode,
129129
const FVergilGraphPin& SourcePin,
130130
const FVergilGraphNode& TargetNode,
@@ -144,23 +144,23 @@ namespace
144144
return FPaths::Combine(FPaths::ProjectSavedDir(), TEXT("Vergil"), TEXT("Benchmarks"), TEXT("LargeGraphBenchmarkSummary.json"));
145145
}
146146

147-
int32 CountEventGraphNodes(UBlueprint* const Blueprint)
147+
int32 CountBenchmarkEventGraphNodes(UBlueprint* const Blueprint)
148148
{
149149
UEdGraph* const EventGraph = Blueprint != nullptr ? FBlueprintEditorUtils::FindEventGraph(Blueprint) : nullptr;
150150
return EventGraph != nullptr ? EventGraph->Nodes.Num() : 0;
151151
}
152152

153-
FVergilGraphDocument BuildLargeGraphDocument(const FVergilLargeGraphBenchmarkScenario& Scenario, int32& OutCommentCount)
153+
FVergilGraphDocument BuildBenchmarkLargeGraphDocument(const FVergilLargeGraphBenchmarkScenario& Scenario, int32& OutCommentCount)
154154
{
155155
OutCommentCount = 0;
156156

157157
FVergilGraphDocument Document;
158158
Document.SchemaVersion = Vergil::SchemaVersion;
159159
Document.BlueprintPath = FString::Printf(TEXT("/Temp/BP_VergilLargeGraphBenchmark_%s"), *Scenario.Name);
160-
Document.Variables = { MakeBoolVariable(TEXT("BenchmarkFlag"), TEXT("false")) };
160+
Document.Variables = { MakeBenchmarkBoolVariable(TEXT("BenchmarkFlag"), TEXT("false")) };
161161

162-
FVergilGraphNode BeginPlayNode = MakeNode(EVergilNodeKind::Event, TEXT("K2.Event.ReceiveBeginPlay"), FVector2D::ZeroVector);
163-
const FVergilGraphPin BeginPlayThenPin = MakePin(UEdGraphSchema_K2::PN_Then, EVergilPinDirection::Output, true);
162+
FVergilGraphNode BeginPlayNode = MakeBenchmarkNode(EVergilNodeKind::Event, TEXT("K2.Event.ReceiveBeginPlay"), FVector2D::ZeroVector);
163+
const FVergilGraphPin BeginPlayThenPin = MakeBenchmarkPin(UEdGraphSchema_K2::PN_Then, EVergilPinDirection::Output, true);
164164
BeginPlayNode.Pins.Add(BeginPlayThenPin);
165165
Document.Nodes.Add(BeginPlayNode);
166166

@@ -174,45 +174,45 @@ namespace
174174
const float BaseX = static_cast<float>(ColumnIndex) * 900.0f;
175175
const float BaseY = static_cast<float>(RowIndex) * 280.0f;
176176

177-
FVergilGraphNode GetterNode = MakeNode(
177+
FVergilGraphNode GetterNode = MakeBenchmarkNode(
178178
EVergilNodeKind::VariableGet,
179179
TEXT("K2.VarGet.BenchmarkFlag"),
180180
FVector2D(BaseX, BaseY + 120.0f));
181-
const FVergilGraphPin GetterValuePin = MakePin(TEXT("BenchmarkFlag"), EVergilPinDirection::Output);
181+
const FVergilGraphPin GetterValuePin = MakeBenchmarkPin(TEXT("BenchmarkFlag"), EVergilPinDirection::Output);
182182
GetterNode.Pins.Add(GetterValuePin);
183183

184-
FVergilGraphNode NotNode = MakeNode(
184+
FVergilGraphNode NotNode = MakeBenchmarkNode(
185185
EVergilNodeKind::Call,
186186
TEXT("K2.Call.Not_PreBool"),
187187
FVector2D(BaseX + 280.0f, BaseY + 120.0f));
188188
NotNode.Metadata.Add(TEXT("OwnerClassPath"), UKismetMathLibrary::StaticClass()->GetClassPathName().ToString());
189-
const FVergilGraphPin NotInputPin = MakePin(TEXT("A"), EVergilPinDirection::Input);
190-
const FVergilGraphPin NotReturnPin = MakePin(UEdGraphSchema_K2::PN_ReturnValue, EVergilPinDirection::Output);
189+
const FVergilGraphPin NotInputPin = MakeBenchmarkPin(TEXT("A"), EVergilPinDirection::Input);
190+
const FVergilGraphPin NotReturnPin = MakeBenchmarkPin(UEdGraphSchema_K2::PN_ReturnValue, EVergilPinDirection::Output);
191191
NotNode.Pins = { NotInputPin, NotReturnPin };
192192

193-
FVergilGraphNode SetterNode = MakeNode(
193+
FVergilGraphNode SetterNode = MakeBenchmarkNode(
194194
EVergilNodeKind::VariableSet,
195195
TEXT("K2.VarSet.BenchmarkFlag"),
196196
FVector2D(BaseX + 560.0f, BaseY + 80.0f));
197-
const FVergilGraphPin SetterExecPin = MakePin(UEdGraphSchema_K2::PN_Execute, EVergilPinDirection::Input, true);
198-
const FVergilGraphPin SetterThenPin = MakePin(UEdGraphSchema_K2::PN_Then, EVergilPinDirection::Output, true);
199-
const FVergilGraphPin SetterValuePin = MakePin(TEXT("BenchmarkFlag"), EVergilPinDirection::Input);
197+
const FVergilGraphPin SetterExecPin = MakeBenchmarkPin(UEdGraphSchema_K2::PN_Execute, EVergilPinDirection::Input, true);
198+
const FVergilGraphPin SetterThenPin = MakeBenchmarkPin(UEdGraphSchema_K2::PN_Then, EVergilPinDirection::Output, true);
199+
const FVergilGraphPin SetterValuePin = MakeBenchmarkPin(TEXT("BenchmarkFlag"), EVergilPinDirection::Input);
200200
SetterNode.Pins = { SetterExecPin, SetterThenPin, SetterValuePin };
201201

202202
Document.Nodes.Add(GetterNode);
203203
Document.Nodes.Add(NotNode);
204204
Document.Nodes.Add(SetterNode);
205205

206-
Document.Edges.Add(MakeEdge(PreviousExecNode, PreviousExecPin, SetterNode, SetterExecPin));
207-
Document.Edges.Add(MakeEdge(GetterNode, GetterValuePin, NotNode, NotInputPin));
208-
Document.Edges.Add(MakeEdge(NotNode, NotReturnPin, SetterNode, SetterValuePin));
206+
Document.Edges.Add(MakeBenchmarkEdge(PreviousExecNode, PreviousExecPin, SetterNode, SetterExecPin));
207+
Document.Edges.Add(MakeBenchmarkEdge(GetterNode, GetterValuePin, NotNode, NotInputPin));
208+
Document.Edges.Add(MakeBenchmarkEdge(NotNode, NotReturnPin, SetterNode, SetterValuePin));
209209

210210
PreviousExecNode = SetterNode;
211211
PreviousExecPin = SetterThenPin;
212212

213213
if (Scenario.CommentStride > 0 && SegmentIndex % Scenario.CommentStride == 0)
214214
{
215-
FVergilGraphNode CommentNode = MakeNode(
215+
FVergilGraphNode CommentNode = MakeBenchmarkNode(
216216
EVergilNodeKind::Comment,
217217
TEXT("UI.Comment"),
218218
FVector2D(BaseX - 120.0f, BaseY - 60.0f));
@@ -327,8 +327,8 @@ bool FVergilLargeGraphBenchmarkTest::RunTest(const FString& Parameters)
327327

328328
const TArray<FVergilLargeGraphBenchmarkScenario> Scenarios =
329329
{
330-
MakeScenario(TEXT("LinearBoolToggleChain_192"), 192, 24, 15.0, 25.0),
331-
MakeScenario(TEXT("LinearBoolToggleChain_384"), 384, 24, 25.0, 40.0)
330+
MakeBenchmarkScenario(TEXT("LinearBoolToggleChain_192"), 192, 24, 15.0, 25.0),
331+
MakeBenchmarkScenario(TEXT("LinearBoolToggleChain_384"), 384, 24, 25.0, 40.0)
332332
};
333333

334334
TArray<FVergilLargeGraphBenchmarkResult> Results;
@@ -339,7 +339,7 @@ bool FVergilLargeGraphBenchmarkTest::RunTest(const FString& Parameters)
339339
for (const FVergilLargeGraphBenchmarkScenario& Scenario : Scenarios)
340340
{
341341
int32 CommentCount = 0;
342-
const FVergilGraphDocument Document = BuildLargeGraphDocument(Scenario, CommentCount);
342+
const FVergilGraphDocument Document = BuildBenchmarkLargeGraphDocument(Scenario, CommentCount);
343343

344344
FVergilLargeGraphBenchmarkResult& BenchmarkResult = Results.AddDefaulted_GetRef();
345345
BenchmarkResult.Name = Scenario.Name;
@@ -350,7 +350,7 @@ bool FVergilLargeGraphBenchmarkTest::RunTest(const FString& Parameters)
350350
BenchmarkResult.MaxPlanSeconds = Scenario.MaxPlanSeconds;
351351
BenchmarkResult.MaxApplySeconds = Scenario.MaxApplySeconds;
352352

353-
TStrongObjectPtr<UBlueprint> PlanningBlueprint = MakeTransientBlueprint();
353+
TStrongObjectPtr<UBlueprint> PlanningBlueprint = MakeBenchmarkTransientBlueprint();
354354
TestNotNull(*FString::Printf(TEXT("%s should create a transient planning Blueprint."), *Scenario.Name), PlanningBlueprint.Get());
355355
if (!PlanningBlueprint.IsValid())
356356
{
@@ -381,7 +381,7 @@ bool FVergilLargeGraphBenchmarkTest::RunTest(const FString& Parameters)
381381
continue;
382382
}
383383

384-
TStrongObjectPtr<UBlueprint> ApplyBlueprint = MakeTransientBlueprint();
384+
TStrongObjectPtr<UBlueprint> ApplyBlueprint = MakeBenchmarkTransientBlueprint();
385385
TestNotNull(*FString::Printf(TEXT("%s should create a transient apply Blueprint."), *Scenario.Name), ApplyBlueprint.Get());
386386
if (!ApplyBlueprint.IsValid())
387387
{
@@ -390,7 +390,7 @@ bool FVergilLargeGraphBenchmarkTest::RunTest(const FString& Parameters)
390390
}
391391

392392
BenchmarkResult.Apply = RunApplyPhase(EditorSubsystem, ApplyBlueprint.Get(), PlanResult.Commands);
393-
BenchmarkResult.AppliedGraphNodeCount = CountEventGraphNodes(ApplyBlueprint.Get());
393+
BenchmarkResult.AppliedGraphNodeCount = CountBenchmarkEventGraphNodes(ApplyBlueprint.Get());
394394

395395
const FString ApplyLabel = FString::Printf(TEXT("%s apply benchmark"), *Scenario.Name);
396396
TestTrue(*FString::Printf(TEXT("%s should succeed."), *ApplyLabel), BenchmarkResult.Apply.bSucceeded);

0 commit comments

Comments
 (0)