Skip to content
Permalink
Browse files

Add FindWords benchmark

  • Loading branch information...
bobbymcr committed Apr 6, 2019
1 parent 8b20775 commit b2c08c99a97225d48f928f6d61b19748d0cb57fe
Showing with 47 additions and 1 deletion.
  1. +45 −0 src/Words.Benchmark/FindWords.cs
  2. +2 −1 src/Words.Benchmark/Program.cs
@@ -0,0 +1,45 @@
// <copyright file="FindWords.cs" company="Brian Rogers">
// Copyright (c) Brian Rogers. All rights reserved.
// </copyright>

namespace Words.Benchmark
{
using System.IO;
using BenchmarkDotNet.Attributes;

[CoreJob]
[MemoryDiagnoser]
public class FindWords
{
private LetterBoxSearch stringSearch;
private LetterBoxStrSearch strSearch;

[GlobalSetup]
public void Setup()
{
this.stringSearch = new LetterBoxSearch(
StringTrie.Load(File.OpenRead("words.txt")),
new LetterBox("RMEWCLTGKAPI"));

this.strSearch = new LetterBoxStrSearch(
StrTrie.Load(File.OpenRead("words.txt")),
new LetterBoxStr(Str.Parse("RMEWCLTGKAPI")));
}

[Benchmark]
public int StringF()
{
int count = 0;
this.stringSearch.Run((w, v) => ++count);
return count;
}

[Benchmark]
public int StrF()
{
int count = 0;
this.strSearch.Run((w, v) => ++count);
return count;
}
}
}
@@ -10,7 +10,8 @@ internal sealed class Program
{
private static void Main()
{
BenchmarkRunner.Run<LoadTrie>();
// BenchmarkRunner.Run<LoadTrie>();
BenchmarkRunner.Run<FindWords>();
}
}
}

0 comments on commit b2c08c9

Please sign in to comment.
You can’t perform that action at this time.