Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp2 {
- public class Benchmark {
- int simpleField;
- public int AutoProperty { get; set; }
- public int SimpleProperty { get { return simpleField; } set { simpleField = value; } }
- public int ComplexProperty { get { return SimpleProperty + 20; } }
- public void GlobalSetup() {
- AutoProperty = 100;
- }
- public void ForSupressJit() {
- simpleField += 10;
- }
- public int ForToAutoProperty() {
- int sum = 0;
- for (int i = 0; i < AutoProperty; i++) {
- sum += i;
- }
- return sum;
- }
- public int ForToSimpleProperty() {
- int sum = 0;
- for(int i = 0; i < SimpleProperty; i++) {
- sum += i;
- }
- return sum;
- }
- public int ForToComplexProperty() {
- int sum = 0;
- for(int i = 0; i < ComplexProperty; i++) {
- sum += i;
- }
- return sum;
- }
- }
- class Program {
- static void Main(string[] args) {
- Benchmark b = new Benchmark();
- b.GlobalSetup();
- b.ForToAutoProperty();
- b.ForToComplexProperty();
- b.ForToSimpleProperty();
- Console.ReadLine();
- b.ForToAutoProperty();
- b.ForToComplexProperty();
- b.ForToSimpleProperty();
- }
- }
- }
Add Comment
Please, Sign In to add comment