How many nanoseconds does the call to GetProperties () make?

Relative: Big-O from .GetProperties ()

How many nanoseconds does the method use .GetProperties()in C #?

EDIT

Tested:

On a simple developer's computer (nothing unusual), an element has 8 properties and does not inherit:

        stopwatch.Start();
        for (int i = 0; i < 10000; i++)
        {
            PropertyInfo[] properties = item.GetType().GetProperties();
        }
        stopwatch.Stop();

Results:

Total time in nanoseconds: 16,569.8 Total time in milliseconds: 16.5698 Average time on .GetProperties () Call: 1.65 ns (this assumption, not sure if the results are cached)

Besides

When you restart with an additional nested foreach loop, it took only 6 milliseconds. Here is the added code (inside the for loop):

            foreach (var prop in properties)
            {
                var x = prop;
            }
+1
source share
1 answer

, , , , .

, . . - , Stopwatch . , , (, ).

+3

All Articles