Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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; | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters