<commit_before>package algoholic

import "testing"

const BENCHMARK_LENGTH = 10

func TestFisherYatesShufflesEvenly(t *testing.T) {
	// Set an arbitrary maximum error from expectation - We expect each number to occur within
	// 1% of the probability in a list of length 10 after 1e6 iterations.
	// TODO: Determine maximum error mathematically.
	checkShufflesEvenly(t, ShuffleFisherYates, 10, 1e6, 0.01)
}

func TestRandomOrderShuffleShufflesEvenly(t *testing.T) {
	// Set an arbitrary maximum error from expectation - We expect each number to occur within
	// 1% of the probability in a list of length 10 after 1e6 iterations.
	// TODO: Determine maximum error mathematically.
	checkShufflesEvenly(t, ShuffleRandomSort, 10, 1e6, 0.01)
}

func BenchmarkFisherYatesShuffle(b *testing.B) {
	benchmarkShuffle(b, BENCHMARK_LENGTH, ShuffleFisherYates)
}

func BenchmarkRandomSortShuffle(b *testing.B) {
	benchmarkShuffle(b, BENCHMARK_LENGTH, ShuffleRandomSort)
}<commit_msg>We can do better with Fisher-Yates :)<commit_after>package algoholic

import "testing"

const BENCHMARK_LENGTH = 10

func TestFisherYatesShufflesEvenly(t *testing.T) {
	// Set an arbitrary maximum error from expectation - We expect each number to occur within
	// 0.7% of the probability in a list of length 10 after 1e6 iterations.
	// TODO: Determine maximum error mathematically.
	checkShufflesEvenly(t, ShuffleFisherYates, 10, 1e6, 0.007)
}

func TestRandomOrderShuffleShufflesEvenly(t *testing.T) {
	// Set an arbitrary maximum error from expectation - We expect each number to occur within
	// 1% of the probability in a list of length 10 after 1e6 iterations.
	// TODO: Determine maximum error mathematically.
	checkShufflesEvenly(t, ShuffleRandomSort, 10, 1e6, 0.01)
}

func BenchmarkFisherYatesShuffle(b *testing.B) {
	benchmarkShuffle(b, BENCHMARK_LENGTH, ShuffleFisherYates)
}

func BenchmarkRandomSortShuffle(b *testing.B) {
	benchmarkShuffle(b, BENCHMARK_LENGTH, ShuffleRandomSort)
}
{'fraction_non_alphanumeric': 0.07735368956743002, 'fraction_numerical': 0.02748091603053435, 'mean_word_length': 5.163009404388715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7237302', 'n_tokens_mistral': 691, 'n_tokens_neox': 624, 'n_words': 204}