The ParaMonte Documentation Website
Current view: top level - kernel/tests - Test_TimerCPU_mod.f90 (source / functions) Hit Total Coverage
Test: ParaMonte 1.5.1 :: MPI Parallel Kernel - Code Coverage Report Lines: 18 18 100.0 %
Date: 2021-01-08 13:07:16 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       2             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
       3             : !!!!
       4             : !!!!   MIT License
       5             : !!!!
       6             : !!!!   ParaMonte: plain powerful parallel Monte Carlo library.
       7             : !!!!
       8             : !!!!   Copyright (C) 2012-present, The Computational Data Science Lab
       9             : !!!!
      10             : !!!!   This file is part of the ParaMonte library.
      11             : !!!!
      12             : !!!!   Permission is hereby granted, free of charge, to any person obtaining a
      13             : !!!!   copy of this software and associated documentation files (the "Software"),
      14             : !!!!   to deal in the Software without restriction, including without limitation
      15             : !!!!   the rights to use, copy, modify, merge, publish, distribute, sublicense,
      16             : !!!!   and/or sell copies of the Software, and to permit persons to whom the
      17             : !!!!   Software is furnished to do so, subject to the following conditions:
      18             : !!!!
      19             : !!!!   The above copyright notice and this permission notice shall be
      20             : !!!!   included in all copies or substantial portions of the Software.
      21             : !!!!
      22             : !!!!   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      23             : !!!!   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      24             : !!!!   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
      25             : !!!!   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
      26             : !!!!   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
      27             : !!!!   OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
      28             : !!!!   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
      29             : !!!!
      30             : !!!!   ACKNOWLEDGMENT
      31             : !!!!
      32             : !!!!   ParaMonte is an honor-ware and its currency is acknowledgment and citations.
      33             : !!!!   As per the ParaMonte library license agreement terms, if you use any parts of
      34             : !!!!   this library for any purposes, kindly acknowledge the use of ParaMonte in your
      35             : !!!!   work (education/research/industry/development/...) by citing the ParaMonte
      36             : !!!!   library as described on this page:
      37             : !!!!
      38             : !!!!       https://github.com/cdslaborg/paramonte/blob/main/ACKNOWLEDGMENT.md
      39             : !!!!
      40             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      41             : !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      42             : 
      43             : !>  \brief This module contains tests of the module [TimerCPU_mod](@ref timercpu_mod).
      44             : !>  \author Amir Shahmoradi
      45             : 
      46             : module Test_TimerCPU_mod
      47             : 
      48             :     use TimerCPU_mod
      49             :     use Test_mod, only: Test_type
      50             :     implicit none
      51             : 
      52             :     private
      53             :     public :: test_TimerCPU
      54             : 
      55             :     type(Test_type) :: Test
      56             : 
      57             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      58             : 
      59             : contains
      60             : 
      61             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      62             : 
      63           3 :     subroutine test_TimerCPU()
      64             : 
      65             :         implicit none
      66             : 
      67           3 :         Test = Test_type(moduleName=MODULE_NAME)
      68           3 :         call Test%run(test_TimerCPU_type_1, "test_TimerCPU_type_1")
      69           3 :         call Test%finalize()
      70             : 
      71           3 :     end subroutine test_TimerCPU
      72             : 
      73             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      74             : 
      75           3 :     function test_TimerCPU_type_1() result(assertion)
      76             : 
      77           3 :         use Constants_mod, only: IK, RK
      78             :         use System_mod, only: sleep
      79             :         implicit none
      80             :         real(RK), parameter :: seconds = 0.05_RK
      81             :         logical             :: assertion
      82           3 :         type(TimerCPU_type) :: TimerCPU
      83             : 
      84           3 :         assertion = .true.
      85             : 
      86             :         ! Note: On macOS the TimerCPU tests fail.
      87             :         ! The CPU timer is neither available on all processors nor is 
      88             :         ! essential for the successful build and run of the ParaMonte library.
      89             :         ! Therefore, it is only tested in code coverage.
      90             : 
      91             : #if defined CODECOV_ENABLED
      92           3 :         TimerCPU = TimerCPU_type()
      93           3 :         assertion = .not. TimerCPU%Err%occurred; if (.not. assertion) return
      94           3 :         call sleep(seconds=seconds,Err=TimerCPU%Err)
      95           3 :         assertion = .not. TimerCPU%Err%occurred; if (.not. assertion) return
      96           3 :         call TimerCPU%toc()
      97           3 :         assertion = assertion .and. TimerCPU%Time%total >= 0._RK
      98           3 :         assertion = assertion .and. TimerCPU%Time%delta >= 0._RK
      99           3 :         assertion = assertion .and. TimerCPU%Time%start <= TimerCPU%Time%stop
     100             : 
     101             :         ! LCOV_EXCL_START
     102             :         if (Test%isDebugMode .and. .not. assertion) then
     103             :             write(Test%outputUnit,"(*(g0))")
     104             :             write(Test%outputUnit,"(*(g0))")   "TimerCPU%Time%start : ", TimerCPU%Time%start
     105             :             write(Test%outputUnit,"(*(g0))")   "TimerCPU%Time%stop  : ", TimerCPU%Time%stop
     106             :             write(Test%outputUnit,"(*(g0))")   "TimerCPU%Time%delta : ", TimerCPU%Time%delta
     107             :             write(Test%outputUnit,"(*(g0))")   "TimerCPU%Time%total : ", TimerCPU%Time%total
     108             :             write(Test%outputUnit,"(*(g0))")   "TimerCPU%Time%unit  : ", TimerCPU%Time%unit
     109             :             write(Test%outputUnit,"(*(g0))")
     110             :         end if
     111             :         ! LCOV_EXCL_STOP
     112             : #endif
     113             : 
     114           3 :     end function test_TimerCPU_type_1
     115             : 
     116             : !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     117             : 
     118             : end module Test_TimerCPU_mod ! LCOV_EXCL_LINE

ParaMonte: Plain Powerful Parallel Monte Carlo Library 
The Computational Data Science Lab
© Copyright 2012 - 2021