public void AfterEach() { m_ByteStringBuffer.Dispose(); m_Int4StringBuffer.Dispose(); m_ByteString.Dispose(); m_Int4String.Dispose(); }
public void BeforeAll() { m_Result = new NativeArray <int>(1, Allocator.Persistent); m_SmallerStrings = TestData.RandomStrings(10, MinLength, MaxLength); m_SmallerBuffer = new Int4StringBuffer(m_SmallerStrings); // this is just to force this job to synchronously compile with Burst before perf test var tempInt4String = new Int4String(m_SmallerStrings[0]); m_SmallJob = new SingleStringSearchJobInt4(tempInt4String, m_SmallerBuffer, m_Result); m_SmallJob.Run(); var array = tempInt4String.IntBytes; Search.FindString(ref array, ref m_SmallerBuffer.Data, ref m_SmallerBuffer.Indices); tempInt4String.Dispose(); m_Strings = TestData.RandomStringsWithPrefix("/composition", StringCount, MinLength, MaxLength); m_Buffer = new Int4StringBuffer(m_Strings); }
public void Search_FindInt4String() { // second to last in the array, so we can test how long it takes to iterate StringCount times var searchForIndex = StringCount - 2; m_String = new Int4String(m_Strings[searchForIndex]); Profiler.BeginSample("Search_FindInt4String"); var array = m_String.IntBytes; var foundIndex = Search.FindString(ref array, ref m_Buffer.Data, ref m_Buffer.Indices); Assert.AreEqual(searchForIndex, foundIndex); Profiler.EndSample(); // jobs make their own profiler label m_Job = new SingleStringSearchJobInt4(m_String, m_Buffer, m_Result); m_Job.Run(); Assert.AreEqual(searchForIndex, m_Job.FoundIndex[0]); m_String.Dispose(); }