Commit 7258ba2 1 parent b8737e5 commit 7258ba2 Copy full SHA for 7258ba2
File tree 2 files changed +44
-0
lines changed
2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 7
7
strategy :
8
8
matrix :
9
9
os : [ubuntu-latest]
10
+ kind : [tests, benchmark]
10
11
fail-fast : false
11
12
12
13
runs-on : ${{ matrix.os }}
38
39
restore-keys : cljdeps-
39
40
40
41
- name : Test helpers
42
+ if : ${{ matrix.kind == 'tests' }}
41
43
run : clojure -M clojure/tests/aoc_tests.clj
42
44
43
45
- name : Test solutions
46
+ if : ${{ matrix.kind == 'tests' }}
44
47
run : clojure -M clojure/tests/solutions_tests.clj
48
+
49
+ - name : Benchmark solutions
50
+ if : ${{ matrix.kind == 'benchmark' }}
51
+ run : clojure -M:profile clojure/tests/solutions_benchmark.clj
Original file line number Diff line number Diff line change
1
+ (ns solutions-benchmark
2
+ (:require
3
+ [criterium.core :as c]
4
+ [clojure.string :as str]
5
+ [clojure.pprint :as pp]
6
+ aoc
7
+ day01 day02 day03 day04 day05
8
+ day06 day07 day08 day09 day10
9
+ day11 day12 day13 day14 day15
10
+ day16 day17 day18 day19 day20
11
+ day21 day22 day23 day24 day25))
12
+
13
+
14
+ (defn extract-time [res]
15
+ (->> res
16
+ str/split-lines
17
+ second
18
+ (drop-while #(not (#{\:} %)))
19
+ rest
20
+ str/join))
21
+
22
+ (def results (atom []))
23
+
24
+ (def first-day 1 )
25
+ (def last-day 25 )
26
+
27
+ (doseq [i (range first-day (inc last-day))]
28
+ (println " BENCHMARKING DAY" i)
29
+ (let [res (with-out-str
30
+ (c/quick-bench ((eval (symbol (format " day%02d" i) " solve" )) (aoc/read-file i))))]
31
+ (println res)
32
+ (swap! results conj {:day i :time (extract-time res)}))
33
+ (println " \n\n\n " ))
34
+
35
+
36
+ (println " SUMMARY:\n " )
37
+ (pp/print-table @results)
You can’t perform that action at this time.
0 commit comments