@@ -20,33 +20,17 @@ using BenchmarkTools, Statistics
20
20
const SUITE = BenchmarkGroup ()
21
21
const N = parse (Int, get (ENV , " BENCH_NUM_ITERS" , " 1000" ))
22
22
23
- decimal_precision = 2
24
-
25
- # Express that data through the various types. Round it for integers.
26
- fd_FixedPointDecimal_types = [
27
- FixedPointDecimals. FixedDecimal{Int32, decimal_precision},
28
- FixedPointDecimals. FixedDecimal{Int64, decimal_precision},
29
- FixedPointDecimals. FixedDecimal{Int128, decimal_precision},
23
+ benchtypes = [
24
+ FixedPointDecimals. FixedDecimal{Int32, 2 },
25
+ FixedPointDecimals. FixedDecimal{Int64, 2 },
26
+ FixedPointDecimals. FixedDecimal{Int128, 2 },
30
27
]
31
- inttypes = [Int32,Int64,Int128]
32
- floattypes = [Float32,Float64]
33
- # bigtypes = [BigInt, BigFloat]
34
-
35
- alltypes = (inttypes... , floattypes... , fd_FixedPointDecimal_types... ,)
36
28
37
29
identity1 (a,_) = a
38
30
allops = (* , / , + , ÷ , identity1)
39
31
40
- # Category for the results output CSV
41
- category (:: Type{<:Union{inttypes...}} ) = " Int"
42
- category (:: Type{<:Union{floattypes...}} ) = " Float"
43
- # category(::Type{<:Union{bigtypes...}}) = "Big"
44
- category (:: Type{<:FixedPointDecimals.FixedDecimal} ) = " FixedDecimal"
45
- type (T:: Type ) = " $T "
46
- type (T:: Type{<:Union{Int32, Int64}} ) = " $T "
47
- type (T:: Type{Int128} ) = " $T "
48
- type (:: Type{FixedPointDecimals.FixedDecimal{T,f}} ) where {T,f} = " FD{$T ,$f }"
49
- type (:: Type{FixedPointDecimals.FixedDecimal{T,f}} ) where {T<: Union{Int32,Int64} ,f} = " FD{ $T ,$f }"
32
+ prettytype (:: Type{FixedPointDecimals.FixedDecimal{T,f}} ) where {T,f} = " FD{$T ,$f }"
33
+ prettytype (:: Type{FixedPointDecimals.FixedDecimal{T,f}} ) where {T<: Union{Int32,Int64} ,f} = " FD{ $T ,$f }"
50
34
opname (f) = string (Symbol (f))
51
35
opname (f:: typeof (identity1)) = " identity"
52
36
79
63
# Define the benchmark structure
80
64
for op in allops
81
65
SUITE[opname (op)] = BenchmarkGroup ()
82
- for T in alltypes
83
- SUITE[opname (op)][type (T)] = BenchmarkGroup ([" base" , " bench" ])
66
+ for T in benchtypes
67
+ SUITE[opname (op)][prettytype (T)] = BenchmarkGroup ([" base" , " bench" ])
84
68
end
85
69
end
86
70
87
71
for op in allops
88
72
println ()
89
73
println (" $op " )
90
- for T in alltypes
74
+ for T in benchtypes
91
75
print (" $T " )
92
76
93
77
initial_value = zero (T)
@@ -99,8 +83,8 @@ for op in allops
99
83
100
84
# Run the benchmark
101
85
outbase = Ref (initial_value)
102
- SUITE[opname (op)][type (T)][" base" ] = @benchmarkable $ fbase ($ outbase) evals= 1 setup= ($ outbase[]= $ initial_value)
86
+ SUITE[opname (op)][prettytype (T)][" base" ] = @benchmarkable $ fbase ($ outbase) evals= 1 setup= ($ outbase[]= $ initial_value)
103
87
outbench = Ref (initial_value)
104
- SUITE[opname (op)][type (T)][" bench" ] = @benchmarkable $ fbench ($ outbench) evals= 1 setup= ($ outbench[]= $ initial_value)
88
+ SUITE[opname (op)][prettytype (T)][" bench" ] = @benchmarkable $ fbench ($ outbench) evals= 1 setup= ($ outbench[]= $ initial_value)
105
89
end
106
90
end
0 commit comments