Announcement

Collapse
No announcement yet.

TArray<FVector2D> much slower than std::vector<FVector2D>?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    TArray<FVector2D> much slower than std::vector<FVector2D>?

    I benchmarked the element access times between a TArray containing FVector2Ds and a std::vector array. TArray performs significantly slower here. I compiled using the default "Development Editor" settings in Visual C++ 19, UE4.22.3, Win7.
    I tend to stick with UE4 libraries wherever possible due to compatibility, but why is it so slow?

    #2
    Do you have logs ?

    Comment


      #3
      I think TArray is garbage collected. Might have something to do with it. Although just access you would think it wouldn't.

      Also, by "slower" how much slower?

      Comment


        #4
        TArray does a bounds check in [] in non-shipping configs. You can skip this with GetData() if really necessary.

        Comment


          #5
          I can't tell you exactly how much slower the array acces only is. I did a loop with some calcluations using values stored in arrays and random numbers to reduce the effect of caching and the TArray-loop took twice as long as std::vector.
          Thanks Zeblote, accessing using GetData() makes it as fast as std::vector.
          Last edited by Houndmux; 09-07-2019, 07:17 AM.

          Comment

          Working...
          X