File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 25
25
(- (.totalMemory (Runtime/getRuntime ))
26
26
(.freeMemory (Runtime/getRuntime ))))
27
27
28
+ (defn rounding-divide
29
+ " Divide two numbers and round them.
30
+
31
+ Unlike quot, this rounds rather than truncates."
32
+ [m n]
33
+ (Math/round (double (/ m n))))
34
+
28
35
(defn start [testable]
29
36
(assoc testable ::start (get-memory )))
30
37
93
100
(doseq [{:keys [::delta :kaocha.testable/id ] :as test} largest
94
101
:let [n (count (remove ::testable/skip (:kaocha.result/tests test)))]]
95
102
(cond
96
- (> n 0 ) (let [avg (long ( Math/round ( / delta n)) )]
103
+ (> n 0 ) (let [avg (rounding-divide delta n )]
97
104
(println (format " %s%s \n %s\0 33[1m%s\0 33[0m average (%s / %d tests)" indentation-str
98
105
id (str indentation-str indentation-str)
99
106
(convert-bytes avg) (convert-bytes delta) n)))
Original file line number Diff line number Diff line change 40
40
(is
41
41
(= " -11B" (gc/convert-bytes -11 )))))
42
42
43
+ (deftest rounding-divide
44
+ (testing " Yielding whole numbers."
45
+ (is
46
+ (= 2 (gc/rounding-divide 4 2 )))
47
+ (is
48
+ (= 2 (gc/rounding-divide 4.0 2 )))
49
+ (is
50
+ (= 2 (gc/rounding-divide 4 2.0 )))
51
+ (is
52
+ (= 2 (gc/rounding-divide 4.0 2.0 ))))
53
+ (testing " Yielding rational numbers as decimals."
54
+ (is
55
+ (= 3 (gc/rounding-divide 5 2 )))
56
+ (is
57
+ (= 3 (gc/rounding-divide 5 2.0 )))
58
+ (is
59
+ (= 3 (gc/rounding-divide 5.0 2 )))
60
+ (is
61
+ (= 3 (gc/rounding-divide 5.0 2.0 ))))
62
+ (testing " Yielding rational numbers as decimals."
63
+ (is
64
+ (= -2 (gc/rounding-divide -5 2 )))
65
+ (is
66
+ (= -2 (gc/rounding-divide -5 2.0 )))
67
+ (is
68
+ (= -2 (gc/rounding-divide -5.0 2 )))
69
+ (is
70
+ (= -2 (gc/rounding-divide -5.0 2.0 )))))
71
+
72
+
43
73
(deftest gc-profiling-test
44
74
(plugin/with-plugins plugin-chain
45
75
(is
You can’t perform that action at this time.
0 commit comments