From f76e00121487d4d6e40fd3d1a444b1b5481c8046 Mon Sep 17 00:00:00 2001 From: Dale Black Date: Tue, 25 Jun 2024 11:58:29 -0700 Subject: [PATCH] try new test approach for benchmark --- test/benchmarks.jl | 52 ---------------------------------------------- test/runtests.jl | 52 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 53 deletions(-) delete mode 100644 test/benchmarks.jl diff --git a/test/benchmarks.jl b/test/benchmarks.jl deleted file mode 100644 index 4c1768a..0000000 --- a/test/benchmarks.jl +++ /dev/null @@ -1,52 +0,0 @@ -using BenchmarkTools - -@testset "Benchmarks" begin - s = 10 # number of samples - e = 1 # number of evals - - # Create an array of input sizes to benchmark for 2D - sizes_2D = [2^i for i in 3:4] - - # Create DataFrames to store the benchmark results - df_dt_2D = DataFrame( - os_info = os_info, - gpu_info = gpu_info, - sizes = sizes_2D, - dt_proposed = Float64[] - ) - - for n in sizes_2D - f = Float32.(rand([0, 1], n, n)) - - if dev != Array - f_dev = dev(f) - dt = @benchmark(transform($boolean_indicator($f_dev)); samples=s, evals=e) - push!(df_dt_2D, [os_info, gpu_info, n, minimum(dt).time]) - end - end - - # Create an array of input sizes to benchmark for 3D - sizes_3D = [2^i for i in 0:2] - - # Create DataFrames to store the benchmark results - df_dt_3D = DataFrame( - os_info = os_info, - gpu_info = gpu_info, - sizes = sizes_3D, - dt_proposed = Float64[] - ) - - for n in sizes_3D - f = Float32.(rand([0, 1], n, n, n)) - - if dev != Array - f_dev = dev(f) - dt = @benchmark(transform($boolean_indicator($f_dev)); samples=s, evals=e) - push!(df_dt_3D, [os_info, gpu_info, n, minimum(dt).time]) - end - end - - # Show the dataframes - @info df_dt_2D - @info df_dt_3D -end \ No newline at end of file diff --git a/test/runtests.jl b/test/runtests.jl index 78379dc..aee01b5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -38,4 +38,54 @@ include("transform.jl") include("utils.jl") # Benchmark the transform function -include("benchmarks.jl") \ No newline at end of file +@testset "Benchmarks" begin + s = 10 # number of samples + e = 1 # number of evals + + # Create an array of input sizes to benchmark for 2D + sizes_2D = [2^i for i in 3:4] + + # Create DataFrames to store the benchmark results + df_dt_2D = DataFrame( + os_info = os_info, + gpu_info = gpu_info, + sizes = sizes_2D, + dt_proposed = Float64[] + ) + + for n in sizes_2D + f = Float32.(rand([0, 1], n, n)) + + if dev != Array + f_dev = dev(f) + dt = @benchmark(transform($boolean_indicator($f_dev)); samples=s, evals=e) + push!(df_dt_2D, [os_info, gpu_info, n, minimum(dt).time]) + end + end + + # Create an array of input sizes to benchmark for 3D + sizes_3D = [2^i for i in 0:2] + + # Create DataFrames to store the benchmark results + df_dt_3D = DataFrame( + os_info = os_info, + gpu_info = gpu_info, + sizes = sizes_3D, + dt_proposed = Float64[] + ) + + for n in sizes_3D + f = Float32.(rand([0, 1], n, n, n)) + + if dev != Array + f_dev = dev(f) + dt = @benchmark(transform($boolean_indicator($f_dev)); samples=s, evals=e) + push!(df_dt_3D, [os_info, gpu_info, n, minimum(dt).time]) + end + end + + # Show the dataframes + @info df_dt_2D + @info df_dt_3D + @test 1 == 1 +end \ No newline at end of file