I am making a plugin, and it works fine in PIE, but after packaging I noticed that it was very slow.
For example, if measure the execution time of the code below
for (unsigned int i = 0; i < 10000000; i++)
{
TArray<TempStruct> test;
test.SetNum(300);
}
it takes about 1 to 0.8 seconds in PIE.
But if test after packaging, it takes about 75 seconds
I also tested the computational speed, either the same or a bit faster in packaging.
int ArrayTemp[] = { 0,1,2,3,4,5,6,7,8,9 };
TArray test;
test.SetNum(300);
for (unsigned int i = 0; i < 10000000; i++)
{
for (int list = 0; list < Test2.Num(); list++)
{
//Test[list].fVariable = 1;
Test[list].fVariable = ArrayTemp[9] / ArrayTemp[8] / ArrayTemp[7] / ArrayTemp[6] / ArrayTemp[5] / ArrayTemp[4] / ArrayTemp[3] / ArrayTemp[2] / ArrayTemp[1];
}
}
Both PIE and packaging came out in about 25 seconds, or 10% to 20% faster in packaging.
Why are these results coming out? And is there a solution?
I solved it temporarily by declaring all the variables to be used on the object.