@@ -20,33 +20,17 @@ using BenchmarkTools, Statistics
2020const SUITE = BenchmarkGroup ()
2121const N = parse (Int, get (ENV , " BENCH_NUM_ITERS" , " 1000" ))
2222
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 },
3027]
31- inttypes = [Int32,Int64,Int128]
32- floattypes = [Float32,Float64]
33- # bigtypes = [BigInt, BigFloat]
34-
35- alltypes = (inttypes... , floattypes... , fd_FixedPointDecimal_types... ,)
3628
3729identity1 (a,_) = a
3830allops = (* , / , + , ÷ , identity1)
3931
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 }"
5034opname (f) = string (Symbol (f))
5135opname (f:: typeof (identity1)) = " identity"
5236
7963# Define the benchmark structure
8064for op in allops
8165 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" ])
8468 end
8569end
8670
8771for op in allops
8872 println ()
8973 println (" $op " )
90- for T in alltypes
74+ for T in benchtypes
9175 print (" $T " )
9276
9377 initial_value = zero (T)
@@ -99,8 +83,8 @@ for op in allops
9983
10084 # Run the benchmark
10185 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)
10387 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)
10589 end
10690end
0 commit comments