I watch courses on C # proffesional from ITVDN. There is an example, for the first time they refer to the dynamic field, which was previously equivalent to an object reference, and show that the first call to such a field takes 2 million ticks. I repeat it on my computer, but I have only 2 thousand ticks. Approximately 10 times more than the following calls to dynamic. The salt is that dynamic remembers the object, but for the first time it knows nothing about it and therefore takes more time. But 2 thousand and 2 million for the same functions - a very big difference. Could the course be outdated and C # developers optimized dynamic? Code:
MyClass c = new MyClass(); dynamic d = c; long start, end; while (true) { QueryPerformanceCounter(out start); dm(); QueryPerformanceCounter(out end); Console.WriteLine((end - start) + '\n'); }