Skip to content

Commit

Permalink
Move benchmark function to single definition
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenJ committed Oct 7, 2024
1 parent b7e356c commit e86c8c9
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

0 comments on commit e86c8c9

Please sign in to comment.