Csc.exe compilation Parameters

Source: Internet
Author: User

/* ------ Calcpi. CS -----*/

Using system;

Public class calcpi
{
Public const int COUNT = 100000000;
Public static void main (string [] ARGs)
{
Datetime start = datetime. now;
Random random = new random (start. millisecond );
Int inside = 0;
For (INT I = 0; I <count; I ++)
{
Double Cx = random. nextdouble ();
Double Cy = random. nextdouble ();
Double distance = math. SQRT (CX * CX) + (CY * CY ));
If (distance <1.0)
{
++ Inside;
}
}
Double Pi = 4 * (double) inside/(double) count;
Datetime end = datetime. now;
Timespan diff = end-start;
Console. writeline ("Pi = {0}", Pi );
Console. writeline ("consumed time: {0} ms", diff. totalmilliseconds );
}

}

 

Note:
1. This instance calculates the circumference RateProgramTo avoid accidental errors, the number of computations is greatly set.

Compilation process description
Compile Parameters File Size File Name Execution time
/Optimize 3,584 bytes Calcpi.exe 8937.5 Ms
/Filealign: 512 3,584 bytes Calcpi512.exe 8843.75 Ms
/Filealign: 1024 5,120 bytes Calcpi1024.exe 9031.25 Ms
/Filealign: 8192 32,768 bytes Calcpi8192.exe 8843.75 Ms

You can see that using the/filealign parameter and bringing a small value (must be a multiple of 512) can reduce the size of the generated file moderately, without affecting execution efficiency. Another problem is that I used optimization but didn't improve the program efficiency. I don't know why.
The following are:

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.