Simple performance test for c, cs, and vala

Source: Internet
Author: User
Perform the same operation with c, cs, and vala respectively: Code
# Include <stdlib. h>
# Include <stdio. h>

Int main ()
{
Printf ("c for begin \ n ");
Int count = 1000000000;
Int I;
For (I = 0; I <count; I ++)
{
;
}
Printf ("c for end \ n ");

Printf ("int add begin \ n ");
Int ncount = 1000000000;
Int n = 0;
Int j;
For (j = 0; j <ncount; j ++)
{
Int a = 3;
Int B = 4;
N = a + B;
}
Printf ("% d", n );
Printf ("int add end \ n ");

Printf ("float add begin \ n ");
Int fcount = 10000000;
Float f = 0.0f;
Int k;
For (k = 0; k <fcount; k ++)
{
Float a = 3.0f;
Float B = 4.0f;
F = a + B;
}
Printf ("% f", f );
Printf ("float add end \ n ");

Return 0;
}

Test result: Code
User @ mojo :~ /Projects/performance/c $ time./c
C for begin
C for end
Int add begin
7int add end
Float add begin
7.000000 float add end

Real 0m49. 264 s
User 0m46. 450 s
Sys 0m0. 010 s

User @ mojo :~ /Projects/performance/cs $ time mono main.exe
C for begin

C for end

Int add begin

7
Int add end

Float add begin

7
Float add end

Real 1m37. 252 s
User 1m31. 880 s
Sys 0m0. 135 s

User @ mojo :~ /Projects/performance/vala $ time./main
C for begin
C for end
Int add begin
7int add end
Float add begin
7.000000 float add end

Real 1m14. 979 s
User 1m10. 995 s
Sys 0m0. 020 s

Ps: all of the above tests were completed on SmartQ5 (cpu: cloud6410 arm11 667 MHz, ram: 128 M), and python and lua were also tested. The conclusion is basically incomparable, crash status.

/Files/zhongzf/src.zip

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.