run part one with goroutines

re-run benchmarks
This commit is contained in:
onyx-and-iris 2024-12-19 19:03:30 +00:00
parent a4e8e83844
commit 52541e7ca7
3 changed files with 24 additions and 16 deletions

View File

@ -2,14 +2,14 @@ goos: linux
goarch: amd64 goarch: amd64
pkg: github.com/onyx-and-iris/aoc2024/day-19 pkg: github.com/onyx-and-iris/aoc2024/day-19
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
BenchmarkSolve-12 1000000000 0.1996 ns/op BenchmarkSolve-12 1000000000 0.09381 ns/op
BenchmarkSolve-12 1000000000 0.2115 ns/op BenchmarkSolve-12 1000000000 0.1010 ns/op
BenchmarkSolve-12 1000000000 0.1903 ns/op BenchmarkSolve-12 1000000000 0.1131 ns/op
BenchmarkSolve-12 1000000000 0.1840 ns/op BenchmarkSolve-12 1000000000 0.09298 ns/op
BenchmarkSolve-12 1000000000 0.1891 ns/op BenchmarkSolve-12 1000000000 0.09649 ns/op
BenchmarkSolve-12 1000000000 0.1828 ns/op BenchmarkSolve-12 1000000000 0.09659 ns/op
BenchmarkSolve-12 1000000000 0.1888 ns/op BenchmarkSolve-12 1000000000 0.1022 ns/op
BenchmarkSolve-12 1000000000 0.1834 ns/op BenchmarkSolve-12 1000000000 0.09501 ns/op
BenchmarkSolve-12 1000000000 0.1895 ns/op BenchmarkSolve-12 1000000000 0.09695 ns/op
BenchmarkSolve-12 1000000000 0.1832 ns/op BenchmarkSolve-12 1000000000 0.1007 ns/op
ok github.com/onyx-and-iris/aoc2024/day-19 24.811s ok github.com/onyx-and-iris/aoc2024/day-19 9.903s

View File

@ -2,5 +2,5 @@ goos: linux
goarch: amd64 goarch: amd64
pkg: github.com/onyx-and-iris/aoc2024/day-19/internal/one pkg: github.com/onyx-and-iris/aoc2024/day-19/internal/one
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
BenchmarkSolve-12 1000000000 0.1706 ns/op BenchmarkSolve-12 1000000000 0.08205 ns/op
ok github.com/onyx-and-iris/aoc2024/day-19/internal/one 2.018s ok github.com/onyx-and-iris/aoc2024/day-19/internal/one 0.765s

View File

@ -18,11 +18,19 @@ func Solve(buf []byte) (int, error) {
log.Debug(stripes, designs) log.Debug(stripes, designs)
var sum int conc := len(designs)
sumChan := make(chan bool)
for _, design := range designs { for _, design := range designs {
ok := isPossibleArrangement(design, stripes) go func() {
ok := isPossibleArrangement(design, stripes)
sumChan <- ok
}()
}
var sum int
for range conc {
ok := <-sumChan
if ok { if ok {
log.Debugf("design: %s is possible", design)
sum++ sum++
} }
} }