Skip to content

Commit

Permalink
feat(aoc2024): Add Macro_TimeExecution
Browse files Browse the repository at this point in the history
  • Loading branch information
vipentti committed Dec 6, 2024
1 parent 47229ec commit 79c9677
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 12 additions & 0 deletions visp/examples/aoc2024/common.visp
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,15 @@
(begin
(ignore (.MoveNext enu))
(+Current enu))])

(syntax-macro Macro_TimeExecution
[(_ op body ...)
(begin
(let sw (.StartNew System.Diagnostics.Stopwatch))

(let result (begin body ...))

(.Stop sw)
(printfn "%s took %fms" op (->> sw +Elapsed +TotalMilliseconds))

result)])
5 changes: 2 additions & 3 deletions visp/examples/aoc2024/day6.visp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
(unless (Add_Visited pos dir)
(set! result true)
(set! looping false))
;; (up! visited (Set.add (pos . dir)))
]
[_
(match (Grid_Get next grid)
Expand Down Expand Up @@ -137,7 +136,7 @@
(let PART1_EXPECTED_RESULT (if IS_EXAMPLE 41 5404))
(let PART2_EXPECTED_RESULT (if IS_EXAMPLE 6 1984))

(WriteResult "part1" (-> parsed Part1) PART1_EXPECTED_RESULT)
(WriteResult "part2" (-> parsed Part2) PART2_EXPECTED_RESULT)
(WriteResult "part1" (Macro_TimeExecution "part1" (-> parsed Part1)) PART1_EXPECTED_RESULT)
(WriteResult "part2" (Macro_TimeExecution "part2" (-> parsed Part2)) PART2_EXPECTED_RESULT)

()

0 comments on commit 79c9677

Please sign in to comment.