-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update version and deps * Fix ci * Fix codeconv
- Loading branch information
Showing
108 changed files
with
3,352 additions
and
18,842 deletions.
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
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
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
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package bench_test | ||
|
||
import ( | ||
"math/rand" | ||
"sort" | ||
"testing" | ||
|
||
"github.com/dnovikoff/tempai-core/compact" | ||
"github.com/dnovikoff/tempai-core/hand/effective" | ||
"github.com/dnovikoff/tempai-core/hand/shanten" | ||
"github.com/dnovikoff/tempai-core/hand/tempai" | ||
"github.com/dnovikoff/tempai-core/tile" | ||
) | ||
|
||
func BenchmarkShanten(b *testing.B) { | ||
repeat := b.N | ||
data := make([]compact.Instances, repeat) | ||
// prepare | ||
source := rand.NewSource(123) | ||
rnd := rand.New(source) | ||
instances := compact.AllInstances().Instances() | ||
for k := range data { | ||
shuffle(rnd, instances) | ||
data[k] = compact.NewInstances().Add(instances[:13]) | ||
} | ||
b.ResetTimer() | ||
for _, v := range data { | ||
shanten.Calculate(v) | ||
} | ||
|
||
b.StopTimer() | ||
b.Log("Repeat: ", repeat) | ||
b.Log("RPS: ", float64(repeat)/b.Elapsed().Seconds()) | ||
} | ||
|
||
func BenchmarkTempai(b *testing.B) { | ||
repeat := b.N | ||
data := make([]compact.Instances, repeat) | ||
// prepare | ||
source := rand.NewSource(123) | ||
rnd := rand.New(source) | ||
instances := compact.AllInstancesFromTo(tile.Sou1, tile.Sou9+1).Instances() | ||
for k := range data { | ||
shuffle(rnd, instances) | ||
data[k] = compact.NewInstances().Add(instances[:13]) | ||
} | ||
cnt := 0 | ||
|
||
b.ResetTimer() | ||
for _, v := range data { | ||
r := tempai.Calculate(v) | ||
if r != nil { | ||
cnt++ | ||
} | ||
} | ||
|
||
b.StopTimer() | ||
b.Log("Repeat: ", repeat) | ||
b.Log("Tempai hand count: ", cnt) | ||
b.Log("RPS: ", float64(repeat)/b.Elapsed().Seconds()) | ||
} | ||
|
||
func BenchmarkEffective(b *testing.B) { | ||
repeat := b.N | ||
data := make([]compact.Instances, repeat) | ||
// prepare | ||
source := rand.NewSource(123) | ||
rnd := rand.New(source) | ||
instances := compact.AllInstances().Instances() | ||
for k := range data { | ||
shuffle(rnd, instances) | ||
data[k] = compact.NewInstances().Add(instances[:14]) | ||
} | ||
|
||
b.ResetTimer() | ||
for _, v := range data { | ||
effective.Calculate(v) | ||
} | ||
|
||
b.StopTimer() | ||
b.Log("Repeat: ", repeat) | ||
b.Log("RPS: ", float64(repeat)/b.Elapsed().Seconds()) | ||
} | ||
|
||
func shuffle(r *rand.Rand, x sort.Interface) { | ||
r.Shuffle(x.Len(), func(i, j int) { x.Swap(i, j) }) | ||
} |
This file was deleted.
Oops, something went wrong.
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
module github.com/dnovikoff/tempai-core | ||
|
||
go 1.15 | ||
go 1.22.6 | ||
|
||
require ( | ||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect | ||
github.com/facebookgo/stackerr v0.0.0-20150612192056-c2fcf88613f4 | ||
github.com/stretchr/testify v1.6.1 | ||
golang.org/x/tools v0.9.1 | ||
github.com/stretchr/testify v1.9.0 | ||
) | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
Oops, something went wrong.