mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-10 06:40:47 +00:00
add benchmarks for one and two
This commit is contained in:
parent
d05828154e
commit
84312b157c
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,6 +7,7 @@
|
|||||||
*.dll
|
*.dll
|
||||||
*.so
|
*.so
|
||||||
*.dylib
|
*.dylib
|
||||||
|
bin/
|
||||||
|
|
||||||
# Test binary, built with `go test -c`
|
# Test binary, built with `go test -c`
|
||||||
*.test
|
*.test
|
||||||
|
6
day-01/internal/one/benchmark
Normal file
6
day-01/internal/one/benchmark
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
pkg: github.com/onyx-and-iris/aoc2024/day-01/internal/one
|
||||||
|
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||||
|
BenchmarkMain-12 1000000000 0.0006628 ns/op
|
||||||
|
ok github.com/onyx-and-iris/aoc2024/day-01/internal/one 0.009s
|
@ -1,11 +1,15 @@
|
|||||||
package main
|
package one
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
_ "embed"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:embed testdata/input.txt
|
||||||
|
var data []byte
|
||||||
|
|
||||||
func BenchmarkMain(b *testing.B) {
|
func BenchmarkMain(b *testing.B) {
|
||||||
os.Stdout, _ = os.Open(os.DevNull)
|
os.Stdout, _ = os.Open(os.DevNull)
|
||||||
main()
|
Solve(data)
|
||||||
}
|
}
|
6
day-01/internal/two/benchmark
Normal file
6
day-01/internal/two/benchmark
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
goos: linux
|
||||||
|
goarch: amd64
|
||||||
|
pkg: github.com/onyx-and-iris/aoc2024/day-01/internal/two
|
||||||
|
cpu: Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
|
||||||
|
BenchmarkMain-12 1000000000 0.001179 ns/op
|
||||||
|
ok github.com/onyx-and-iris/aoc2024/day-01/internal/two 0.011s
|
15
day-01/internal/two/solve_internal_test.go
Normal file
15
day-01/internal/two/solve_internal_test.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package two
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "embed"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed testdata/input.txt
|
||||||
|
var data []byte
|
||||||
|
|
||||||
|
func BenchmarkMain(b *testing.B) {
|
||||||
|
os.Stdout, _ = os.Open(os.DevNull)
|
||||||
|
Solve(data)
|
||||||
|
}
|
@ -1,40 +0,0 @@
|
|||||||
/********************************************************************************
|
|
||||||
Advent of Code 2024 - day-01
|
|
||||||
********************************************************************************/
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"embed"
|
|
||||||
"flag"
|
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/onyx-and-iris/aoc2024/day-01/internal/one"
|
|
||||||
"github.com/onyx-and-iris/aoc2024/day-01/internal/two"
|
|
||||||
)
|
|
||||||
|
|
||||||
//go:embed testdata
|
|
||||||
var files embed.FS
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
filename := flag.String("f", "input.txt", "input file")
|
|
||||||
flag.Parse()
|
|
||||||
|
|
||||||
data, err := files.ReadFile(fmt.Sprintf("testdata/%s", *filename))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
val, err := one.Solve(data)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
fmt.Printf("solution one: %d\n", val)
|
|
||||||
|
|
||||||
val, err = two.Solve(data)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
fmt.Printf("solution two: %d\n", val)
|
|
||||||
}
|
|
23
day-01/solve.go
Normal file
23
day-01/solve.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package day01
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
|
"github.com/onyx-and-iris/aoc2024/day-01/internal/one"
|
||||||
|
"github.com/onyx-and-iris/aoc2024/day-01/internal/two"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Solve(data []byte) {
|
||||||
|
val, err := one.Solve(data)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Printf("solution one: %d\n", val)
|
||||||
|
|
||||||
|
val, err = two.Solve(data)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Printf("solution two: %d\n", val)
|
||||||
|
}
|
15
day-01/solve_internal_test.go
Normal file
15
day-01/solve_internal_test.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package day01
|
||||||
|
|
||||||
|
import (
|
||||||
|
_ "embed"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed testdata/input.txt
|
||||||
|
var data []byte
|
||||||
|
|
||||||
|
func BenchmarkMain(b *testing.B) {
|
||||||
|
os.Stdout, _ = os.Open(os.DevNull)
|
||||||
|
Solve(data)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user