<commit_before>﻿using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Tasks;

namespace BenchmarkDotNet.Samples.JIT
{
    // See: https://alexandrnikitin.github.io/blog/dotnet-generics-under-the-hood/
    [BenchmarkTask(platform: BenchmarkPlatform.X86, jitVersion: BenchmarkJitVersion.LegacyJit)]
    [BenchmarkTask(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.LegacyJit)]
    [BenchmarkTask(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.RyuJit)]
    public class Jit_GenericsMethod
    {
        private class BaseClass<T>
        {
            private List<T> list = new List<T>();

            public BaseClass()
            {
                Enumerable.Empty<T>();
            }

            public void Run()
            {
                for (var i = 0; i < 11; i++)
                    if (list.Any())
                        return;
            }
        }

        private class DerivedClass : BaseClass<object>
        {
        }

        private BaseClass<object> baseClass = new BaseClass<object>();
        private BaseClass<object> derivedClass = new DerivedClass();

        [Benchmark]
        public void Base()
        {
            baseClass.Run();
        }

        [Benchmark]
        public void Derived()
        {
            derivedClass.Run();
        }
    }
}<commit_msg>Change Jit_GenericsMethod benchmark to reproduce on x64 both Legacy & RuyJit<commit_after>﻿using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Tasks;

namespace BenchmarkDotNet.Samples.JIT
{
    // See: https://alexandrnikitin.github.io/blog/dotnet-generics-under-the-hood/
    [BenchmarkTask(platform: BenchmarkPlatform.X86, jitVersion: BenchmarkJitVersion.LegacyJit)]
    [BenchmarkTask(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.LegacyJit)]
    [BenchmarkTask(platform: BenchmarkPlatform.X64, jitVersion: BenchmarkJitVersion.RyuJit)]
    public class Jit_GenericsMethod
    {
        private class BaseClass<T>
        {
            private List<T> list = new List<T>();

            public BaseClass()
            {
                foreach (var _ in list) { }
            }

            public void Run()
            {
                for (var i = 0; i < 11; i++)
                    if (list.Any(_ => true))
                        return;
            }
        }

        private class DerivedClass : BaseClass<object>
        {
        }

        private BaseClass<object> baseClass = new BaseClass<object>();
        private BaseClass<object> derivedClass = new DerivedClass();

        [Benchmark]
        public void Base()
        {
            baseClass.Run();
        }

        [Benchmark]
        public void Derived()
        {
            derivedClass.Run();
        }
    }
}
{'fraction_non_alphanumeric': 0.09896391568417291, 'fraction_numerical': 0.007145409074669525, 'mean_word_length': 1.9166666666666667, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 19, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5318516', 'n_tokens_mistral': 853, 'n_tokens_neox': 792, 'n_words': 159}