public unsafe void TestProfilerThreadsCantInitializeTwice()
        {
            ProfilerProtocolThread.Shutdown();
            Thread thread = new Thread(() => { ProfilerProtocolThread.Initialize(); });

            thread.Start();
            thread.Join();
            Assert.Throws <InvalidOperationException>(() => ProfilerProtocolThread.Initialize());
            ProfilerProtocolThread.Shutdown();
        }
        public static void BurstedProfilerMethods(ref ProfilerMarker marker)
        {
            EnsureBurstedOrThrow();

            // These API calls actually prove out a LOT of internal API burst-ability
            marker.Begin();
            marker.End();

            using (marker.Auto())
            {
            }

            ProfilerProtocolThread.SendNewFrame();
        }
        public unsafe void TestProfilerThreadsHaveUniqueStreams()
        {
            ProfilerProtocolThread.Shutdown();
            ProfilerProtocolThread.Initialize();

            Thread[] threads = new Thread[16];
            IntPtr[] streams = new IntPtr[16];
            for (int i = 0; i < threads.Length; i++)
            {
                threads[i] = new Thread((object p) =>
                {
                    int pi = (int)p;
                    Assert.Zero(ProfilerProtocolThread.Stream.buffer->m_BufferList->TotalBytes);
                    fixed(ProfilerProtocolStream * s = &ProfilerProtocolThread.Stream)
                    streams[pi] = (IntPtr)s;
                    ProfilerProtocolThread.SendNewFrame();
                });
                threads[i].Start(i);
            }

            for (int i = 0; i < threads.Length; i++)
            {
                threads[i].Join();
            }

            for (int i = 0; i < threads.Length; i++)
            {
                ProfilerProtocolStream *stream = (ProfilerProtocolStream *)streams[i];
                Assert.NotZero(stream->buffer->m_BufferList->TotalBytes);
                for (int j = 0; j < threads.Length; j++)
                {
                    Assert.IsTrue(streams[i] != streams[j] || i == j);
                }
            }

            ProfilerProtocolThread.Shutdown();
        }