Show More
Commit Description:
Add timers for Simulation and various engines...
Commit Description:
Add timers for Simulation and various engines Starting to add additional timers for different stages of the process of updating in order to get more insight into what is slowing it down. The update takes 9ms, which is much longer than it used to. Engine-specific timers are coming later.
File last commit:
Show/Diff file:
Action:
ImGui.NET/RangeAccessor.cs
68 lines | 1.8 KiB | text/x-csharp | CSharpLexer
Add ImGui.
r16 using System;
using System.Runtime.CompilerServices;
using System.Text;
namespace ImGuiNET
{
public unsafe struct RangeAccessor<T> where T : struct
{
private static readonly int s_sizeOfT = Unsafe.SizeOf<T>();
public readonly void* Data;
public readonly int Count;
public RangeAccessor(IntPtr data, int count) : this(data.ToPointer(), count) { }
public RangeAccessor(void* data, int count)
{
Data = data;
Count = count;
}
public ref T this[int index]
{
get
{
if (index < 0 || index >= Count)
{
throw new IndexOutOfRangeException();
}
return ref Unsafe.AsRef<T>((byte*)Data + s_sizeOfT * index);
}
}
}
public unsafe struct RangePtrAccessor<T> where T : struct
{
public readonly void* Data;
public readonly int Count;
public RangePtrAccessor(IntPtr data, int count) : this(data.ToPointer(), count) { }
public RangePtrAccessor(void* data, int count)
{
Data = data;
Count = count;
}
public T this[int index]
{
get
{
if (index < 0 || index >= Count)
{
throw new IndexOutOfRangeException();
}
return Unsafe.Read<T>((byte*)Data + sizeof(void*) * index);
}
}
}
public static class RangeAccessorExtensions
{
public static unsafe string GetStringASCII(this RangeAccessor<byte> stringAccessor)
{
return Encoding.ASCII.GetString((byte*)stringAccessor.Data, stringAccessor.Count);
}
}
}