Skip to content

Commit

Permalink
Export test utils to separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
fhagemann committed Nov 5, 2024
1 parent 6dd481d commit 41ef21f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 56 deletions.
57 changes: 1 addition & 56 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# This file is a part of SolidStateDetectors.jl, licensed under the MIT License (MIT).
using Test

# using CUDAKernels # Uncomment this line in order to run all tests on (CUDA) GPU
using SolidStateDetectors

using SpecialFunctions
Expand All @@ -10,64 +9,10 @@ using Statistics
using StatsBase
using Tables, TypedTables
using Unitful
using TimerOutputs

include("test_utils.jl")

T = Float32
device_array_type = (@isdefined CUDAKernels) ? CUDAKernels.CUDA.CuArray : Array


testtimer() = get_timer("_default_testtimer_")

macro timed_testset(title, body)
quote
tmr = testtimer()
_title = $(esc(title))
@timeit tmr "$_title" begin
@testset "$_title" begin
$(esc(body))
end
end
end
end


function timed_calculate_electric_potential!(args...; kwargs...)
@timeit testtimer() "calculate_electric_potential!" begin
calculate_electric_potential!(args...; kwargs...)
end
end

function timed_calculate_electric_field!(args...; kwargs...)
@timeit testtimer() "calculate_electric_field!" begin
calculate_electric_field!(args...; kwargs...)
end
end

function timed_calculate_weighting_potential!(args...; kwargs...)
@timeit testtimer() "calculate_weighting_potential!" begin
calculate_weighting_potential!(args...; kwargs...)
end
end

function timed_simulate_waveforms(args...; kwargs...)
@timeit testtimer() "simulate_waveforms" begin
simulate_waveforms(args...; kwargs...)
end
end

function timed_simulate!(args...; kwargs...)
@timeit testtimer() "simulate!" begin
simulate!(args...; kwargs...)
end
end

function timed_estimate_depletion_voltage(args...; kwargs...)
@timeit testtimer() "estimate_depletion_voltage" begin
estimate_depletion_voltage(args...; kwargs...)
end
end


@timed_testset "Comparison to analytic solutions" begin
include("comparison_to_analytic_solutions.jl")
Expand Down
57 changes: 57 additions & 0 deletions test/test_utils.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This file is a part of SolidStateDetectors.jl, licensed under the MIT License (MIT).

using TimerOutputs
# using CUDAKernels # Uncomment this line in order to run all tests on (CUDA) GPU

device_array_type = (@isdefined CUDAKernels) ? CUDAKernels.CUDA.CuArray : Array

testtimer() = get_timer("_default_testtimer_")

macro timed_testset(title, body)
quote
tmr = testtimer()
_title = $(esc(title))
@timeit tmr "$_title" begin
@testset "$_title" begin
$(esc(body))
end
end
end
end


function timed_calculate_electric_potential!(args...; kwargs...)
@timeit testtimer() "calculate_electric_potential!" begin
calculate_electric_potential!(args...; kwargs...)
end
end

function timed_calculate_electric_field!(args...; kwargs...)
@timeit testtimer() "calculate_electric_field!" begin
calculate_electric_field!(args...; kwargs...)
end
end

function timed_calculate_weighting_potential!(args...; kwargs...)
@timeit testtimer() "calculate_weighting_potential!" begin
calculate_weighting_potential!(args...; kwargs...)
end
end

function timed_simulate_waveforms(args...; kwargs...)
@timeit testtimer() "simulate_waveforms" begin
simulate_waveforms(args...; kwargs...)
end
end

function timed_simulate!(args...; kwargs...)
@timeit testtimer() "simulate!" begin
simulate!(args...; kwargs...)
end
end

function timed_estimate_depletion_voltage(args...; kwargs...)
@timeit testtimer() "estimate_depletion_voltage" begin
estimate_depletion_voltage(args...; kwargs...)
end
end

0 comments on commit 41ef21f

Please sign in to comment.