Comparison of TCC execution efficiency and C # execution efficiency in Snapman systems

Source: Internet
Author: User

Snapman Collection The TCC compiler can directly compile and execute C script, its script execution efficiency and C # compiler program efficiency comparison, including the following 3 aspects:

1. Function execution Efficiency

2. Convert numbers into strings

3. Stacking of strings

This is the C # code:

usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespacetestefficiency{ Public Partial classForm1:form { PublicForm1 () {InitializeComponent (); }        intFibonacciintN) {if(n = =1|| n = =2)                return 1; returnFibonacci (N-1) + Fibonacci (N-2); }        stringNumberconvert () {stringresult ="";  for(inti =0; I <14000000; i++) {result=i.tostring (); }            returnresult; }        stringStringappend () {stringConc ="StringBuilder sb = new StringBuilder (1024x768);"; StringBuilder SB=NewStringBuilder (1024x768);  for(inti =0; I <1400; i++) {SB=NewStringBuilder (1024x768);  for(intj =0; J <10000; J + +) {sb.                Append (CONC); }            }            returnsb.        ToString (); }        Private voidButton1_Click (Objectsender, EventArgs e) {DateTime Fbefordt=System.DateTime.Now; Fibonacci ( $); DateTime Fafterdt=System.DateTime.Now; TimeSpan TS=fafterdt.subtract (Fbefordt); TextBox1.Text=string. Format ("Fibonacci spend: {0}ms.", TS.            TotalMilliseconds); DateTime Nbefordt=System.DateTime.Now;            Numberconvert (); DateTime Nafterdt=System.DateTime.Now; TimeSpan NTS=nafterdt.subtract (Nbefordt); TextBox2.Text=string. Format ("Numberconvert spend: {0}ms.", NTS.            TotalMilliseconds); DateTime Sbefordt=System.DateTime.Now;            Stringappend (); DateTime Safterdt=System.DateTime.Now; TimeSpan STS=safterdt.subtract (Sbefordt); TextBox3.Text=string. Format ("stringappend spend: {0}ms.", Sts.        TotalMilliseconds); }    }}

This is the page that C # compiles out of release:

This is the TCC script code written in the Snapman system:

intFibonacciintN) {if(n==1|| n==2)          return 1; returnFibonacci (n1) + Fibonacci (n2); }Char*Numberconvert () {Char* result = (Char*)malloc( -);  for(inti =0; I <14000000; i++) {itoa (I,result,Ten); }    returnresult;}Char*Stringappend () {Char* Conc ="StringBuilder sb = new StringBuilder (1024x768);"; Char* SB = (Char*)malloc(1024x768),*p; intLen =1024x768, cl = strlen (conc), Curlen =0;  for(inti =0; I <1400; i++)    {         Free(SB); Len=1024x768; Curlen=0; SB= (Char*)malloc(1024x768);  for(intj =0; J <10000; J + +)        {            if(Curlen + CL >Len) {P= (Char*)malloc(len*2);                memcpy (P,sb,curlen);  Free(SB); SB=p; Len*=2; } memcpy (SB+CURLEN,CONC,CL); Curlen+=cl; }} Sb[curlen]=0; returnsb;}voidMain () {intSTARTICC =GetTickCount (); Fibonacci ( $); Wprint (L"Fibonacci spend:%dms", GetTickCount ()-STARTICC); STARTICC=GetTickCount ();  Free(Numberconvert ()); Wprint (L"Numberconvert spend:%dms", GetTickCount ()-STARTICC); STARTICC=GetTickCount ();  Free(Stringappend ()); Wprint (L"stringappend spend:%dms", GetTickCount ()-STARTICC);}

This is the Snapman page:

The two codes are designed and implemented in exactly the same way that the results of their operation compare:

C # Execution Results:

Snapman Execution Results:

Conclusion: The comparison results show that C # In addition to the most efficient StringBuilder and TCC string operation execution speed is much slower than the speed of Snapman, so the Snapman script runs very fast.

Snapman's homepage: http://www.snapman.xyz

Comparison of TCC execution efficiency and C # execution efficiency in Snapman systems

Related Article

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.