<commit_before>﻿using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AXFSoftware.Security.Cryptography.Turing;
using System.Diagnostics;

namespace PerfTests
{
    class Program
    {
        const int Size = 10000000;
        const int NumberOfRuns = 5;

        Tuple<TimeSpan,int> DoRun(ICryptoTransform transform, byte [] clear, byte [] cipher)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            int count = 0;
            while (count < Size)
                count += transform.TransformBlock(clear, 0, transform.InputBlockSize / 8, cipher, 0);
            stopwatch.Stop();
            return Tuple.Create(stopwatch.Elapsed, count);
        }

        double MBPerSecond(int size, TimeSpan time)
        {
            double mb = size / 1000000;
            return Math.Round(mb / time.TotalSeconds, 3);
        }

        void TimeRun<T>() where T : Turing, new()
        {
            var turing = new T();
            string name = turing.GetType().Name;
            Console.WriteLine($"{name}: ");

            turing.Key = Encoding.ASCII.GetBytes("test key 128bits");
            byte[] clear = new byte[340];
            byte[] cipher = new byte[clear.Length];
            TimeSpan totalTime = new TimeSpan(0);
            int totalSize = 0;
            for(int run = 0; run < NumberOfRuns; run++)
            {
                var tuple = DoRun(turing.CreateEncryptor(), clear, cipher);
                Console.WriteLine($"{tuple.Item1}   ({MBPerSecond(tuple.Item2, tuple.Item1)} MB/sec)");
                totalTime += tuple.Item1;
                totalSize += tuple.Item2;
            }
            TimeSpan averageTime = TimeSpan.FromMilliseconds(totalTime.TotalMilliseconds / NumberOfRuns);
            int averageSize = totalSize / NumberOfRuns;<commit_msg>To test perf, measure big segment<commit_after>﻿using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AXFSoftware.Security.Cryptography.Turing;
using System.Diagnostics;

namespace PerfTests
{
    class Program
    {
        const int Size = ((10000000 / TuringTransform.BlockSizeBytes) + 1) * TuringTransform.BlockSizeBytes;
        const int NumberOfRuns = 5;

        Tuple<TimeSpan,int> DoRun(ICryptoTransform transform, byte [] clear, byte [] cipher)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            int count = transform.TransformBlock(clear, 0, Size, cipher, 0);
            stopwatch.Stop();
            return Tuple.Create(stopwatch.Elapsed, count);
        }

        double MBPerSecond(int size, TimeSpan time)
        {
            double mb = size / 1000000;
            return Math.Round(mb / time.TotalSeconds, 3);
        }

        void TimeRun<T>() where T : Turing, new()
        {
            var turing = new T();
            string name = turing.GetType().Name;
            Console.WriteLine($"{name}: ");

            turing.Key = Encoding.ASCII.GetBytes("test key 128bits");
            byte[] clear = new byte[Size];
            byte[] cipher = new byte[clear.Length];
            TimeSpan totalTime = new TimeSpan(0);
            int totalSize = 0;
            for(int run = 0; run < NumberOfRuns; run++)
            {
                var tuple = DoRun(turing.CreateEncryptor(), clear, cipher);
                Console.WriteLine($"{tuple.Item1}   ({MBPerSecond(tuple.Item2, tuple.Item1)} MB/sec)");
                totalTime += tuple.Item1;
                totalSize += tuple.Item2;
            }
            TimeSpan averageTime = TimeSpan.FromMilliseconds(totalTime.TotalMilliseconds / NumberOfRuns);
            int averageSize = totalSize / NumberOfRuns;
{'fraction_non_alphanumeric': 0.10760475944128298, 'fraction_numerical': 0.017071908949818936, 'mean_word_length': 2.0886581469648564, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6849393', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1046, 'n_words': 261}