Permutations: Difference between revisions

m
Line 2,080:
 
=== Fortran Speed Test ===
So, ... what is the fastest algorithm?
 
Here below is the speed test for a couple of algorithms of permutation. We can add more algorithms into this frame-work. When they work in the same circumstance, we can see which is the fastest one.
Line 2,146:
! Finishing (1)
!
write(*,*) "1) subnexper: (3rt fast with ifort, 2nd with gfortran)"
write(*,*) 'Total permutations :', ic
write(*,*) 'Total time elapsed :', dt
Line 2,170:
! Finishing (2)
!
write(*,*) "2) Recursiongenerate: (slowest, ifort and gfortran)"
write(*,*) 'Total permutations :', ic
write(*,*) 'Total time elapsed :', dt
Line 2,192:
! Finishing (3)
!
write(*,*) "3) Recursionperm: (2nd fast with ifort, 3rt with gfortran)"
write(*,*) 'Total permutations :', ic
write(*,*) 'Total time elapsed :', dt
Line 2,234:
! Finishing (4)
!
write(*,*) "4) nextp: (1st fast, ifort and gfortran)"
write(*,*) 'Total permutations :', ic
write(*,*) 'Total time elapsed :', dt
Line 2,455:
10
N = 10
1) subnexper: (3rt fast with ifort, 2nd with gfortran)
Total permutations : 3628800
Total time elapsed : 4.9000000000000002E-002
2) generate:
2) Recursion: (slowest, ifort and gfortran)
Total permutations : 3628800
Total time elapsed : 0.84299999999999997
3) perm:
3) Recursion: (2nd fast with ifort, 3rt with gfortran)
Total permutations : 3628800
Total time elapsed : 5.6000000000000001E-002
4) nextp: (1st fast, ifort and gfortran)
Total permutations : 3628800
Total time elapsed : 2.9999999999999999E-002
Line 2,475:
10
N = 10
1) subnexper: (3rt fast with ifort, 2nd with gfortran)
Total permutations : 3628800
Total time elapsed : 8.240000000000000E-002
2) generate:
2) Recursion: (slowest, ifort and gfortran)
Total permutations : 3628800
Total time elapsed : 0.616200000000000
3) perm:
3) Recursion: (2nd fast with ifort, 3rt with gfortran)
Total permutations : 3628800
Total time elapsed : 5.760000000000000E-002
4) nextp: (1st fast, ifort and gfortran)
Total permutations : 3628800
Total time elapsed : 3.600000000000000E-002
 
So far, we have conclusion from the above performance:
3)+ Recursion:subnexper (2ndis the 3rd fast with ifort, 3rtand the 2nd with gfortran).
+ generate is the slowest one with not only ifort but gfortran.
3)+ Recursion:perm is the (2nd fast one with ifort, 3rtand the 3rd one with gfortran).
+ nextp is the fastest one with both ifort and gfortran. (The winner in this test)
 
Note: It is worth mentioning that the performance of this test is dependent not only on algorithm, but also on computer where the test runs. Therefore we should run the test on our own computer and make conclusion by ourselves.
 
=== Fortran 77 ===
Anonymous user