Ejemplo n.º 1
0
        private static void GetPropertiesInstance(int iterations)
        {
            var customer = new Customer();

            var propertyAccess = MeasureIterations(iterations, () => { var result = customer.GetType().GetProperties(); });
            Console.WriteLine("Instance GetType GetProperties: " + propertyAccess);

            // Note: This form must still call GetType() every iteration
            var cachedPropertyAccess = MeasureIterations(iterations, () => { var result = customer.Cachify().GetProperties(); });
            Console.WriteLine("Instance Cachify GetProperties: " + cachedPropertyAccess);
        }
Ejemplo n.º 2
0
        private static void GetClassAttributesInstance(int iterations)
        {
            var customer = new Customer();

            var classAttributeAccess = MeasureIterations(iterations,
                () => { var result = customer.GetType().GetCustomAttributes(false); });
            Console.WriteLine("Instance GetClassAttributes: " + classAttributeAccess);

            var cachedClassAttributeAccess = MeasureIterations(iterations, () => { var result = customer.Cachify().GetAttributes(); });
            Console.WriteLine("Instance Cachify GetAttributes: " + cachedClassAttributeAccess);
        }