Skip to content

Commit

Permalink
Fixed the backwards compatible benchmark support library require (#1125)
Browse files Browse the repository at this point in the history
Previous benchmark require fix wasn't actually working correctly for the
old style require (or running in Lua).
  • Loading branch information
WheretIB authored Dec 4, 2023
1 parent 765ac75 commit aafea36
Show file tree
Hide file tree
Showing 104 changed files with 208 additions and 104 deletions.
3 changes: 2 additions & 1 deletion bench/bench_support.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ end
-- and 'false' otherwise.
--
-- Example usage:
-- local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
-- local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
-- local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")
-- function testFunc()
-- ...
-- end
Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_BinaryTree.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_GC_Boehm_Trees.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
--!nonstrict
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

local stretchTreeDepth = 18 -- about 16Mb
local longLivedTreeDepth = 16 -- about 4Mb
Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_GC_Tree_Pruning_Eager.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()
local count = 1
Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_GC_Tree_Pruning_Gen.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()
local count = 1
Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_GC_Tree_Pruning_Lazy.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()
local count = 1
Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_GC_hashtable_Keyval.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()
local t = {}
Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_LB_mandel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]]
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_LargeTableCtor_array.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_LargeTableCtor_hash.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_Pcall_pcall_yield.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_SunSpider_3d-raytrace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_TableCreate_nil.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_TableCreate_number.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_TableCreate_zerofill.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_TableMarshal_select.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_TableMarshal_table_pack.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/gc/test_TableMarshal_varargs.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_AbsSum_abs.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_AbsSum_and_or.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_AbsSum_math_abs.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_Assert.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_Factorial.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_Failure_pcall_a_bar.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_Failure_pcall_game_Foo.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_Failure_xpcall_a_bar.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_Failure_xpcall_game_Foo.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_LargeTableCtor_array.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_LargeTableCtor_hash.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_LargeTableSum_loop_index.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_LargeTableSum_loop_ipairs.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_LargeTableSum_loop_iter.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_LargeTableSum_loop_pairs.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_MethodCalls.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_OOP_constructor.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_OOP_method_call.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_OOP_virtual_constructor.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_Pcall_call_return.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_Pcall_pcall_return.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_Pcall_pcall_yield.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_Pcall_xpcall_return.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_SqrtSum_exponent.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_SqrtSum_math_sqrt.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_SqrtSum_sqrt.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_SqrtSum_sqrt_getfenv.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_SqrtSum_sqrt_roundabout.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_StringInterp.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

bench.runCode(function()
for j=1,1e6 do
Expand Down
3 changes: 2 additions & 1 deletion bench/micro_tests/test_TableCreate_nil.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local bench = script and require(script.Parent.bench_support) or pcall(require, "bench_support") or require("../bench_support")
local function prequire(name) local success, result = pcall(require, name); return if success then result else nil end
local bench = script and require(script.Parent.bench_support) or prequire("bench_support") or require("../bench_support")

function test()

Expand Down
Loading

0 comments on commit aafea36

Please sign in to comment.