Programming Language EF speed test (5): Binary-trees

Source: Internet
Author: User

This is a specialized programming language/compiler speed test/comparison site (http://shootout.alioth.debian.org/) Given the question,

The following is the source code of EF:

// Binary-treespublic class startup class <author = "liigo"> {const int mindepth = 4; public static main () {int time = runtime environment. take start time (); int n = 16; int maxdepth = N; If (mindepth + 2> N) maxdepth = mindepth + 2; int stretchdepth = maxdepth + 1; int check = (treenode. bottomuptree (0, stretchdepth )). itemcheck (); console. output line ("stretch tree of depth", stretchdepth, "/T check:", check); treenode longlivedtree = treenode. bottomuptree (0, maxdepth); For (INT depth = mindepth; depth <= maxdepth; depth + = 2) {int iterations = 1 <(maxdepth-depth + mindepth ); check = 0; For (INT I = 1; I <= iterations; I ++) {check + = (treenode. bottomuptree (I, depth )). itemcheck (); check + = (treenode. bottomuptree (-I, depth )). itemcheck ();} console. output line (iterations * 2), "/T trees of depth", depth, "/T check:", check);} console. output line ("long lived tree of depth", maxdepth, "/T check:", longlivedtree. itemcheck (); console. output line ("Time (MS):", runtime environment. take the start time ()-time); console. input text ();} private class treenode {private treenode left, right; private int item; Public Init (INT item) {This. item = item;} public static treenode bottomuptree (INT item, int depth) {If (depth> 0) {return New treenode (bottomuptree (2 * item-1, depth-1), bottomuptree (2 * item, depth-1), item);} else {return New treenode (item) ;}} public Init (treenode left, treenode right, int item) {This. left = left; this. right = right; this. item = item;} public int itemcheck () {// if necessary deallocate hereif (Left = NULL) return item; else return item + left. itemcheck ()-Right. itemcheck ();}}}

This EF program runs on my machine for about 108 seconds.The optimized vc6 takes about 6.9 seconds.

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

For this test, EF is the worst since the start of the competition, which is slower than most languages and faster than Ruby, PHP, JavaScript, Perl, TCL and REBOL. The two features of this test are recursion and the creation of a large number of small objects (about 30 million). EF does not seem to be doing well in these two aspects.

(The performance of vc6 is also poor .)

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.