diff --git a/fpm.toml b/fpm.toml index 00f31cc..34fdc91 100644 --- a/fpm.toml +++ b/fpm.toml @@ -22,4 +22,11 @@ kinds = {git="https://github.com/gha3mi/kinds.git"} [[test]] name = "test1" source-dir = "test" -main = "test1.f90" \ No newline at end of file +main = "test1.f90" + +[[test]] +name = "benchmark" +source-dir = "test" +main = "benchmark.f90" +[test.dependencies] +fortime = {git="https://github.com/gha3mi/fortime.git"} \ No newline at end of file diff --git a/test/benchmark.f90 b/test/benchmark.f90 new file mode 100644 index 0000000..11f911a --- /dev/null +++ b/test/benchmark.f90 @@ -0,0 +1,47 @@ +program benchmark + + use kinds + use foreig, only: eig + use fortime, only: timer + + implicit none + + real(rk), dimension(:,:), allocatable :: A + real(rk), dimension(:,:), allocatable :: eig_vec + real(rk), dimension(:), allocatable :: eig_val + integer :: m, i, ntests + type(timer) :: t + + m = 100 + + allocate(A(m,m), eig_vec(m,m), eig_val(m)) + call random_number(A) + A = A*10.0_rk + + + ntests = 5 + + call t%timer_start() + do i = 1, ntests + call eig(A, eig_vec, eig_val, method='syev') + end do + call t%timer_stop(nloops=ntests, message='Elapsed time (syev): ') + + + call t%timer_start() + do i = 1, ntests + call eig(A, eig_vec, eig_val, method='geev') + end do + call t%timer_stop(nloops=ntests, message='Elapsed time (geev): ') + + + call t%timer_start() + do i = 1, ntests + call eig(A, eig_vec, eig_val, method='ggev') + end do + call t%timer_stop(nloops=ntests, message='Elapsed time (ggev): ') + + + deallocate(A, eig_vec, eig_val) + +end program benchmark