Skip to content

Commit 48f11b6

Browse files
committed
Add benchmark for 2021-12
1 parent e94d275 commit 48f11b6

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

Diff for: 2021/12/main_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
import (
4+
u "github.com/vsliouniaev/aoc/util"
5+
"testing"
6+
)
7+
8+
func BenchmarkPart1(t *testing.B) {
9+
for i := 0; i < t.N; i++ {
10+
part1(u.RelativeFile("input"))
11+
}
12+
}
13+
14+
func BenchmarkPart2(t *testing.B) {
15+
for i := 0; i < t.N; i++ {
16+
part2(u.RelativeFile("input"))
17+
}
18+
}

Diff for: util/nav/grid_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ func TestIterator(t *testing.T) {
1010
{1, 2},
1111
{3, 4},
1212
}
13-
i := g.GetIterator()
14-
for p := i.Next(); p != nil; p = i.Next() {
13+
14+
for i, p := g.GetIterator(); p != nil; p = i.Next() {
1515
fmt.Printf("%s = %d\n", p, g.Get(p).(int))
1616
}
1717

Diff for: util/nav/point_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
func TestRotate(t *testing.T) {
88
p := Point{X: 10, Y: 4}
99
p.Rotate(Right)
10-
if p.X != -10 && p.Y != 4 {
10+
if p.X != 4 && p.Y != -10 {
1111
t.Errorf("Expected right turn to perform 90 degrees clockwise")
1212
}
1313
}

Diff for: util/parse.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,10 @@ func RelativeFile(file string) string {
103103
_, b, _, _ := runtime.Caller(1)
104104
path, err := os.Getwd()
105105
Check(err)
106-
return filepath.Join(strings.TrimPrefix(filepath.Dir(b), path)[1:], file)
106+
trimPath := strings.TrimPrefix(filepath.Dir(b), path)
107+
if trimPath == "" {
108+
return filepath.Join(path, file)
109+
} else {
110+
return filepath.Join(trimPath[1:], file)
111+
}
107112
}

0 commit comments

Comments
 (0)