- commit
- 31aba7fdb0740572e0f5f60658a9afa02c33604f
- parent
- 28e7fd57edca7cf472c74e91f3347a7164518cc9
- author
- Dami <dami.etoile@gmail.com>
| M | hashiwokakero/ | 11 | +++++++++++ |
| M | hitori/ | 11 | +++++++++++ |
| M | lightsout/ | 11 | +++++++++++ |
| M | nonogram/ | 11 | +++++++++++ |
| M | nurikabe/ | 11 | +++++++++++ |
| M | shikaku/ | 11 | +++++++++++ |
| M | sudoku/ | 19 | +++++++++++++++++++ |
| M | takuzu/ | 11 | +++++++++++ |
| M | wordsearch/ | 11 | +++++++++++ |
@@ -5,6 +5,13 @@ import (
55 "testing"66 )77 8+func skipBenchmarkInShortMode(b *testing.B) {9+ b.Helper()10+ if testing.Short() {11+ b.Skip("skipping benchmark in short mode")12+ }13+}14+815 func benchmarkHashiModesByBoardSize() []HashiMode {916 return []HashiMode{1017 NewMode("Hard 7x7", "benchmark", 7, 7, 17, 20),@@ -15,6 +22,8 @@ func benchmarkHashiModesByBoardSize() []HashiMode {
1522 }1623 1724 func BenchmarkGeneratePuzzleByBoardSize(b *testing.B) {25+ skipBenchmarkInShortMode(b)26+1827 for modeIndex, mode := range benchmarkHashiModesByBoardSize() {1928 mode := mode2029 modeIndex := modeIndex@@ -44,6 +53,8 @@ func BenchmarkGeneratePuzzleByBoardSize(b *testing.B) {
4453 }4554 4655 func BenchmarkBuildSpanningTree(b *testing.B) {56+ skipBenchmarkInShortMode(b)57+4758 for modeIndex, mode := range benchmarkHashiModesByBoardSize() {4859 mode := mode4960 modeIndex := modeIndex@@ -6,6 +6,13 @@ import (
66 "testing"77 )88 9+func skipBenchmarkInShortMode(b *testing.B) {10+ b.Helper()11+ if testing.Short() {12+ b.Skip("skipping benchmark in short mode")13+ }14+}15+916 type hitoriBenchMode struct {1017 size int1118 blackRatio float64@@ -21,6 +28,8 @@ var hitoriBenchModes = []hitoriBenchMode{
2128 }2229 2330 func BenchmarkGenerateBySize(b *testing.B) {31+ skipBenchmarkInShortMode(b)32+2433 for _, mode := range hitoriBenchModes {2534 name := fmt.Sprintf("%dx%d", mode.size, mode.size)2635 b.Run(name, func(b *testing.B) {@@ -41,6 +50,8 @@ func BenchmarkGenerateBySize(b *testing.B) {
4150 }4251 4352 func BenchmarkCountPuzzleSolutionsBySize(b *testing.B) {53+ skipBenchmarkInShortMode(b)54+4455 for _, mode := range hitoriBenchModes {4556 name := fmt.Sprintf("%dx%d", mode.size, mode.size)4657 b.Run(name, func(b *testing.B) {@@ -5,7 +5,16 @@ import (
55 "testing"66 )77 8+func skipBenchmarkInShortMode(b *testing.B) {9+ b.Helper()10+ if testing.Short() {11+ b.Skip("skipping benchmark in short mode")12+ }13+}14+815 func BenchmarkGenerateByMode(b *testing.B) {16+ skipBenchmarkInShortMode(b)17+918 cases := []struct {1019 name string1120 w int@@ -30,6 +39,8 @@ func BenchmarkGenerateByMode(b *testing.B) {
3039 }3140 3241 func BenchmarkToggle(b *testing.B) {42+ skipBenchmarkInShortMode(b)43+3344 cases := []struct {3445 name string3546 w int@@ -1258,7 +1258,16 @@ func TestHelpToggleInvalidatesOriginCache(t *testing.T) {
12581258 12591259 // --- Benchmarks (P2) ---12601260 1261+func skipBenchmarkInShortMode(b *testing.B) {1262+ b.Helper()1263+ if testing.Short() {1264+ b.Skip("skipping benchmark in short mode")1265+ }1266+}1267+12611268 func BenchmarkGenerateRandomTomographyModes(b *testing.B) {1269+ skipBenchmarkInShortMode(b)1270+12621271 modeConfigs := []struct {12631272 name string12641273 mode NonogramMode@@ -1295,6 +1304,8 @@ func BenchmarkGenerateRandomTomographyModes(b *testing.B) {
12951304 }12961305 12971306 func BenchmarkCountSolutionsLarge(b *testing.B) {1307+ skipBenchmarkInShortMode(b)1308+12981309 cases := []struct {12991310 name string13001311 mode NonogramMode@@ -786,7 +786,16 @@ func TestNoGoroutineLeakOnDeadlineTimeout(t *testing.T) {
786786 787787 // --- Benchmarks (P2) ---788788 789+func skipBenchmarkInShortMode(b *testing.B) {790+ b.Helper()791+ if testing.Short() {792+ b.Skip("skipping benchmark in short mode")793+ }794+}795+789796 func BenchmarkGenerateSeededModes(b *testing.B) {797+ skipBenchmarkInShortMode(b)798+790799 for i, item := range Modes {791800 mode := item.(NurikabeMode)792801 modeIdx := i@@ -805,6 +814,8 @@ func BenchmarkGenerateSeededModes(b *testing.B) {
805814 }806815 807816 func BenchmarkCountSolutions(b *testing.B) {817+ skipBenchmarkInShortMode(b)818+808819 easyMode := Modes[1].(NurikabeMode)809820 easyRNG := rand.New(rand.NewPCG(7001, 9001))810821 easyPuzzle, err := GenerateSeeded(easyMode, easyRNG)@@ -5,6 +5,13 @@ import (
55 "testing"66 )77 8+func skipBenchmarkInShortMode(b *testing.B) {9+ b.Helper()10+ if testing.Short() {11+ b.Skip("skipping benchmark in short mode")12+ }13+}14+815 func benchmarkShikakuModes() []ShikakuMode {916 return []ShikakuMode{1017 NewMode("Mini 5x5", "benchmark", 5, 5, 5),@@ -27,6 +34,8 @@ func makeUncoveredGenerationGrid(width, height int) [][]int {
2734 }2835 2936 func BenchmarkGeneratePuzzleBySize(b *testing.B) {37+ skipBenchmarkInShortMode(b)38+3039 for modeIndex, mode := range benchmarkShikakuModes() {3140 mode := mode3241 modeIndex := modeIndex@@ -56,6 +65,8 @@ func BenchmarkGeneratePuzzleBySize(b *testing.B) {
5665 }5766 5867 func BenchmarkPartitionGrid(b *testing.B) {68+ skipBenchmarkInShortMode(b)69+5970 for modeIndex, mode := range benchmarkShikakuModes() {6071 mode := mode6172 modeIndex := modeIndex@@ -6,6 +6,13 @@ import (
66 "testing"77 )88 9+func skipBenchmarkInShortMode(b *testing.B) {10+ b.Helper()11+ if testing.Short() {12+ b.Skip("skipping benchmark in short mode")13+ }14+}15+916 func benchmarkSudokuModes() []SudokuMode {1017 return []SudokuMode{1118 NewMode("Beginner", "benchmark", 45),@@ -18,6 +25,8 @@ func benchmarkSudokuModes() []SudokuMode {
1825 }1926 2027 func BenchmarkGenerateProvidedCellsByMode(b *testing.B) {28+ skipBenchmarkInShortMode(b)29+2130 for modeIndex, mode := range benchmarkSudokuModes() {2231 mode := mode2332 modeIndex := modeIndex@@ -35,6 +44,8 @@ func BenchmarkGenerateProvidedCellsByMode(b *testing.B) {
3544 }3645 3746 func BenchmarkCountSolutionsByDifficulty(b *testing.B) {47+ skipBenchmarkInShortMode(b)48+3849 for modeIndex, mode := range benchmarkSudokuModes() {3950 mode := mode4051 modeIndex := modeIndex@@ -60,6 +71,8 @@ func BenchmarkCountSolutionsByDifficulty(b *testing.B) {
6071 }6172 6273 func BenchmarkGenerateProvidedCellsSeededStable(b *testing.B) {74+ skipBenchmarkInShortMode(b)75+6376 mode := NewMode("Hard", "benchmark", 27)6477 b.ReportAllocs()6578 for i := 0; i < b.N; i++ {@@ -72,6 +85,8 @@ func BenchmarkGenerateProvidedCellsSeededStable(b *testing.B) {
7285 }7386 7487 func BenchmarkCountSolutionsFixedPuzzle(b *testing.B) {88+ skipBenchmarkInShortMode(b)89+7590 mode := NewMode("Expert", "benchmark", 22)7691 cells := GenerateProvidedCellsSeeded(mode, rand.New(rand.NewPCG(42, 84)))7792 source := newGrid(cells)@@ -91,6 +106,8 @@ func BenchmarkCountSolutionsFixedPuzzle(b *testing.B) {
91106 }92107 93108 func BenchmarkIsValidAllCells(b *testing.B) {109+ skipBenchmarkInShortMode(b)110+94111 mode := NewMode("Medium", "benchmark", 32)95112 cells := GenerateProvidedCellsSeeded(mode, rand.New(rand.NewPCG(7, 11)))96113 g := newGrid(cells)@@ -113,6 +130,8 @@ func BenchmarkIsValidAllCells(b *testing.B) {
113130 }114131 115132 func BenchmarkCountSolutionsModesSummary(b *testing.B) {133+ skipBenchmarkInShortMode(b)134+116135 modes := benchmarkSudokuModes()117136 b.ReportAllocs()118137 for i := 0; i < b.N; i++ {@@ -6,6 +6,13 @@ import (
66 "testing"77 )88 9+func skipBenchmarkInShortMode(b *testing.B) {10+ b.Helper()11+ if testing.Short() {12+ b.Skip("skipping benchmark in short mode")13+ }14+}15+916 type takuzuBenchMode struct {1017 size int1118 prefilled float64@@ -19,6 +26,8 @@ var takuzuBenchModes = []takuzuBenchMode{
1926 }2027 2128 func BenchmarkGeneratePuzzleSizes(b *testing.B) {29+ skipBenchmarkInShortMode(b)30+2231 for _, mode := range takuzuBenchModes {2332 name := fmt.Sprintf("%dx%d", mode.size, mode.size)2433 b.Run(name, func(b *testing.B) {@@ -38,6 +47,8 @@ func BenchmarkGeneratePuzzleSizes(b *testing.B) {
3847 }3948 4049 func BenchmarkCountSolutionsSizes(b *testing.B) {50+ skipBenchmarkInShortMode(b)51+4152 for _, mode := range takuzuBenchModes {4253 name := fmt.Sprintf("%dx%d", mode.size, mode.size)4354 b.Run(name, func(b *testing.B) {@@ -5,6 +5,13 @@ import (
55 "testing"66 )77 8+func skipBenchmarkInShortMode(b *testing.B) {9+ b.Helper()10+ if testing.Short() {11+ b.Skip("skipping benchmark in short mode")12+ }13+}14+815 type wordSearchBenchCase struct {916 name string1017 width int@@ -16,6 +23,8 @@ type wordSearchBenchCase struct {
1623 }1724 1825 func BenchmarkGenerateWordSearchByMode(b *testing.B) {26+ skipBenchmarkInShortMode(b)27+1928 cases := []wordSearchBenchCase{2029 {2130 name: "easy_10x10",@@ -82,6 +91,8 @@ func BenchmarkGenerateWordSearchByMode(b *testing.B) {
8291 }8392 8493 func BenchmarkTryPlaceWord(b *testing.B) {94+ skipBenchmarkInShortMode(b)95+8596 cases := []struct {8697 name string8798 width int