Skip to content

Commit

Permalink
Refactor: Employ table.shuffle in the benchmark scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rdw-software committed Feb 22, 2024
1 parent e6241ae commit 97795d4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
9 changes: 1 addition & 8 deletions Benchmarks/base64-decode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ local availableBenchmarks = {
end,
}

local function shuffle(tbl)
for i = #tbl, 2, -1 do
local j = math.random(i)
tbl[i], tbl[j] = tbl[j], tbl[i]
end
end

shuffle(availableBenchmarks)
table.shuffle(availableBenchmarks)

for _, benchmark in ipairs(availableBenchmarks) do
benchmark()
Expand Down
9 changes: 1 addition & 8 deletions Benchmarks/base64-encode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,7 @@ local availableBenchmarks = {
end,
}

local function shuffle(tbl)
for i = #tbl, 2, -1 do
local j = math.random(i)
tbl[i], tbl[j] = tbl[j], tbl[i]
end
end

shuffle(availableBenchmarks)
table.shuffle(availableBenchmarks)

for _, benchmark in ipairs(availableBenchmarks) do
benchmark()
Expand Down
9 changes: 1 addition & 8 deletions Benchmarks/cpp-ffi-bitops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,7 @@ local availableBenchmarks = {
end,
}

local function shuffle(tbl)
for i = #tbl, 2, -1 do
local j = math.random(i)
tbl[i], tbl[j] = tbl[j], tbl[i]
end
end

shuffle(availableBenchmarks)
table.shuffle(availableBenchmarks)

for _, benchmark in ipairs(availableBenchmarks) do
benchmark()
Expand Down

0 comments on commit 97795d4

Please sign in to comment.