You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main_test.go 789B

12345678910111213141516171819202122232425262728293031323334353637
  1. package main
  2. import (
  3. "github.com/csmith/aoc-2019/common"
  4. "github.com/csmith/aoc-2019/intcode"
  5. "testing"
  6. )
  7. func Benchmark_Part1(b *testing.B) {
  8. for i := 0; i < b.N; i++ {
  9. input := common.ReadCsvAsInts("input.txt")
  10. memory := make([]int, len(input))
  11. copy(memory, input)
  12. vm := intcode.NewVirtualMachine(memory)
  13. vm.Input = make(chan int, 1)
  14. vm.Output = make(chan int, 1)
  15. vm.Input <- 1
  16. go vm.Run()
  17. _ = common.Last(vm.Output)
  18. }
  19. }
  20. func Benchmark_Part2(b *testing.B) {
  21. for i := 0; i < b.N; i++ {
  22. input := common.ReadCsvAsInts("input.txt")
  23. memory := make([]int, len(input))
  24. copy(memory, input)
  25. vm := intcode.NewVirtualMachine(memory)
  26. vm.Input = make(chan int, 1)
  27. vm.Output = make(chan int, 1)
  28. vm.Input <- 2
  29. go vm.Run()
  30. _ = common.Last(vm.Output)
  31. }
  32. }