<commit_before>﻿using System;
using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
using NinjaNye.SearchExtensions.Levenshtein;

namespace NinjaNye.SearchExtensions.Tests.LevenshteinTests
{
    [TestFixture]
    public class LevenshteinDistancePerformanceTests : BuildStringTestsBase
    {
        #if DEBUG
        // Performance test will always fail in debug mode
        [Ignore]
    	#endif
        [Test]
        public void ToLevenshteinDistance_CompareOneMillionStringsOfLength7_ExecutesInLessThanOneSecond()
        {
            //Arrange
            var words = this.BuildWords(1000000, 7, 7);
            var randomWord = this.BuildRandomWord(7,7);
            var stopwatch = new Stopwatch();
            //Act
            stopwatch.Start();
            var result = words.Select(w => LevenshteinProcessor.LevenshteinDistance(w, randomWord)).ToList();
            stopwatch.Stop();

            //Assert
            Console.WriteLine("Elapsed Time: {0}", stopwatch.Elapsed);<commit_msg>Update performance tests to use TestData attribute<commit_after>﻿using System;
using System.Diagnostics;
using System.Linq;
using NUnit.Framework;
using NinjaNye.SearchExtensions.Levenshtein;

namespace NinjaNye.SearchExtensions.Tests.LevenshteinTests
{
#if DEBUG
    // Performance test will always fail in debug mode
    [Ignore]
#endif
    [TestFixture]
    public class LevenshteinDistancePerformanceTests : BuildStringTestsBase
    {
        [TestCase(6)]
        [TestCase(7)]
        public void ToLevenshteinDistance_CompareOneMillionStringsOfLengthX_ExecutesInLessThanOneSecond(int length)
        {
            //Arrange
            var words = this.BuildWords(1000000, length, length);
            var randomWord = this.BuildRandomWord(length,length);
            var stopwatch = new Stopwatch();
            //Act
            stopwatch.Start();
            var result = words.Select(w => LevenshteinProcessor.LevenshteinDistance(w, randomWord)).ToList();
            stopwatch.Stop();

            //Assert
            Console.WriteLine("Elapsed Time: {0}", stopwatch.Elapsed);
{'fraction_non_alphanumeric': 0.08749405611031859, 'fraction_numerical': 0.010936757013789824, 'mean_word_length': 2.7841726618705036, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6350260', 'n_tokens_mistral': 603, 'n_tokens_neox': 568, 'n_words': 125}