<commit_before>﻿using System;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Columns;
using BenchmarkDotNet.Attributes.Jobs;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

namespace Pingu.Benchmarks
{
    [OrderProvider(SummaryOrderPolicy.FastestToSlowest)]
    [RankColumn(NumeralSystem.Stars)]
    [LegacyJitX64Job, RyuJitX64Job, MonoJob]
    [Config(typeof(Config))]
    public class Adler32Implementations
    {
        class Config : ManualConfig
        {
            public Config ()
            {
                Add(Job.Mono.With(Jit.Llvm).WithId("LlvmMono"));
            }
        }

        Random rand = new Random();
        byte[] data = new byte[77];

        [Setup]
        public void SetupData() => rand.NextBytes(data);

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        unsafe void Do16(byte* buf, ref uint a, ref uint b) { Do8(buf, 0, ref a, ref b); Do8(buf, 8, ref a, ref b); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        unsafe void Do8(byte* buf, int i, ref uint a, ref uint b) { Do4(buf, i, ref a, ref b); Do4(buf, i + 4, ref a, ref b); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        unsafe void Do4(byte* buf, int i, ref uint a, ref uint b) { Do2(buf, i, ref a, ref b); Do2(buf, i + 2, ref a, ref b); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        unsafe void Do2(byte* buf, int i, ref uint a, ref uint b) { Do1(buf, i, ref a, ref b); Do1(buf, i + 1, ref a, ref b); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        unsafe void Do1(byte* buf, int i, ref uint a, ref uint b) { a += buf[i]; b += a; }

        [Benchmark]
        public unsafe int Smartest()
        {
            uint a = 1, b = 0;
            const int nmax = 5552;

            fixed (byte* ptr = data) {
                byte* buf = ptr;
                int len = data.Length, k;
                while (len > 0) {
                    k = len < nmax ? (int)len : nmax;
                    len -= k;<commit_msg>Benchmark: Clean up configuration<commit_after>﻿using System;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Attributes.Columns;
using BenchmarkDotNet.Attributes.Jobs;
using BenchmarkDotNet.Mathematics;
using BenchmarkDotNet.Order;

namespace Pingu.Benchmarks
{
    [OrderProvider(SummaryOrderPolicy.FastestToSlowest)]
    [RankColumn(NumeralSystem.Arabic)]
    [RyuJitX64Job, LegacyJitX64Job, MonoJob]
    public class Adler32Implementations
    {
        Random rand = new Random();
        byte[] data = new byte[77];

        [Setup]
        public void SetupData() => rand.NextBytes(data);

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        unsafe void Do16(byte* buf, ref uint a, ref uint b) { Do8(buf, 0, ref a, ref b); Do8(buf, 8, ref a, ref b); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        unsafe void Do8(byte* buf, int i, ref uint a, ref uint b) { Do4(buf, i, ref a, ref b); Do4(buf, i + 4, ref a, ref b); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        unsafe void Do4(byte* buf, int i, ref uint a, ref uint b) { Do2(buf, i, ref a, ref b); Do2(buf, i + 2, ref a, ref b); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        unsafe void Do2(byte* buf, int i, ref uint a, ref uint b) { Do1(buf, i, ref a, ref b); Do1(buf, i + 1, ref a, ref b); }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        unsafe void Do1(byte* buf, int i, ref uint a, ref uint b) { a += buf[i]; b += a; }

        [Benchmark]
        public unsafe int Smartest()
        {
            uint a = 1, b = 0;
            const int nmax = 5552;

            fixed (byte* ptr = data) {
                byte* buf = ptr;
                int len = data.Length, k;
                while (len > 0) {
                    k = len < nmax ? (int)len : nmax;
                    len -= k;
{'fraction_non_alphanumeric': 0.11451692005885238, 'fraction_numerical': 0.016674840608141245, 'mean_word_length': 2.489307100085543, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '3217657', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1293, 'n_words': 395}