From 901713805df2b24d3decbacabca4641077f4b254 Mon Sep 17 00:00:00 2001 From: Reuben Gardos Reid <5456207+ReubenJ@users.noreply.github.com> Date: Tue, 20 Feb 2024 16:46:42 +0100 Subject: [PATCH] Move benchmark function to single definition --- benchmark/benchmarks.jl | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index e5af5b3..0e65cd3 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -9,14 +9,27 @@ const SUITE = BenchmarkGroup() SUITE["interpret"] = BenchmarkGroup() +function example_function(input1) + if input1 % 5 == 0 && input1 % 3 == 0 + return "FizzBuzz" + elseif input1 % 3 == 0 + return "Fizz" + elseif input1 % 5 == 0 + return "Buzz" + else + return string(input1) + end +end + tab = Dict{Symbol, Any}( :% => rem, :(==) => ==, :string => string, :Int => Int64, :String => String, - :input1 => 15 + :input1 => 15, + :example_function => example_function ) -SUITE["interpret"]["compiled"] = @benchmarkable example = (input1) -> if input1 % 5 == 0 && input1 % 3 == 0 return "FizzBuzz" else string(input1) end -SUITE["interpret"]["compiled"] = @benchmarkable interpret(tab, :(if input1 % 5 == 0 && input1 % 3 == 0 return "FizzBuzz" else string(input1) end)) +SUITE["interpret"]["compiled"] = @benchmarkable example_function(15) +SUITE["interpret"]["interpreted"] = @benchmarkable interpret(tab, :(example_function(input1)))