Programming Language EF speed test (3): fannkuch

Source: Internet
Author: User

This is a dedicatedProgramming Language/Compiler speed test/compare the questions given by the website (http://shootout.alioth.debian.org,

The following are efSource code:

// Fannkuchpublic final class startup class <author = "liigo"> {public static main () {int n = 11; int time = runtime environment. take the start time (); console. output ("pfannkuchen (", N, ") =", fannkuch (N), "/N"); console. output line ("Time (MS):", runtime environment. take the start time ()-time); console. input text ();} static int fannkuch (int n) {int [] perm = new int [N]; int [] perm1 = new int [N]; int [] Count = new int [N]; int flips; int flipsmax; int R; int I; int K; int didpr; int n1 = n-1; if (n <1) return 0; f Or (I = 0; I <n; I ++) perm1 [I] = I;/* Initial (trivial) permu */r = N; didpr = 0; flipsmax = 0; For (;) {If (didpr <30) {for (I = 0; I <n; I ++) console. output (1 + perm1 [I]); console. output line (""); didpr ++ ;}for (; R! = 1; r --) {count [r-1] = r;} If (! (Perm1 [0] = 0 | perm1 [N1] = N1) {flips = 0; for (I = 1; I <n; I ++) {perm [I] = perm1 [I];} k = perm1 [0];/* cache perm [0] In K */do {/* k! = 0 => K> 0 */Int J; For ({I = 1; j = K-1;}; I <j; {I ++; j --;}) {int t_mp = perm [I]; perm [I] = perm [J]; perm [J] = t_mp;} flips ++; /** now exchange K (caching perm [0]) and perm [k] */J = perm [k]; perm [k] = K; k = J ;} while (K! = 0); If (flipsmax <flips) {flipsmax = flips ;}}for (;) {If (r = N) {return flipsmax ;} /* rotate down perm [0 .. r] by one */INT perm0 = perm1 [0]; I = 0; while (I <r) {k = I + 1; perm1 [I] = perm1 [k]; I = K;} perm1 [R] = perm0; count [R]-= 1; if (count [R]> 0) {break ;}r ++ ;}}}}

This efProgramIt takes about 37 seconds to run on my machine.The optimized vc6 takes about 5.8 seconds.

Other Programming Language/compiler performance, please see here: http://shootout.alioth.debian.org/gp4/benchmark.php? Test = fannkuch & lang = all

In general, EF performance is not bad. It is much slower than many programming languages (such as C ++, Java, C #, D, Fortran, and Pascal), and is much slower than many other programming languages (such as Erlang, Python, Ruby, Perl, PHP, Lua, groovy, smalltalk, JavaScript) is much faster.

Further analysis: EF, as a compilation language, is generally slower than other compilation languages (after all, EF compiler has not been optimized), up to seven times slower; EF is usually faster than interpreted languages, usually several times faster, dozens of times faster, or even hundreds of times faster.

There are still a lot of test questions to continue. To learn EF language, please go to EF official blog: http://blog.csdn.net/efdev/

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.