In relation to: Big-O of .GetProperties()
How many nanoseconds does the .GetProperties()
method take in C#?
EDIT
Tested:
On simple dev computer (nothing fancy), item has 8 properties, and no inheritance:
stopwatch.Start();
for (int i = 0; i < 10000; i++)
{
PropertyInfo[] properties = item.GetType().GetProperties();
}
stopwatch.Stop();
Results:
Moreover
When ran a second time with an extra nested foreach loop this only took a total of 6 milliseconds. Here is the added code (inside the for loop):
foreach (var prop in properties)
{
var x = prop;
}