Skip to content

Commit

Permalink
Add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
gha3mi committed Jul 25, 2023
1 parent 10bacee commit 36dcf11
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fpm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@ kinds = {git="https://github.com/gha3mi/kinds.git"}
[[test]]
name = "test1"
source-dir = "test"
main = "test1.f90"
main = "test1.f90"

[[test]]
name = "benchmark"
source-dir = "test"
main = "benchmark.f90"
[test.dependencies]
fortime = {git="https://github.com/gha3mi/fortime.git"}
47 changes: 47 additions & 0 deletions test/benchmark.f90
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 36dcf11

Please sign in to comment.