[C #] How time-consuming to log programs

Source: Internet
Author: User

Many times it takes time for the output program to be recorded,


always start recording the current point of time at the beginning of the program execution, at the end of the record end point in time, and then subtract two times, so is there any other way to be a little bit more presentable? Tell you, there is a drop; ) the subject of this method is Stopwatch
 His description is: For accurate measurement of the running time, you need to record time-consuming students who applause?  Specific use: System.Diagnostics. Stopwatch Stopwatch = new System.Diagnostics.Stopwatch (); stopwatch. Start (); //here: time-consuming process/method needs to be calculated stopwatch. Stop (); stopwatch. Elapsed. totalseconds //Here is the total running seconds of the output, accurate to milliseconds

            System.Diagnostics.Stopwatch Stopwatch = new System.Diagnostics.Stopwatch ();            Stopwatch. Start ();            Byte[] A = System.IO.File.ReadAllBytes ("x:\\ new text document. txt");            Textbox2.appendtext ("\ r \ n Load file length {1} time {0} seconds  ".) Formatwith (stopwatch. Elapsed.totalseconds, A.length));            Stopwatch. Reset (); Stopwatch. Start ();            Byte[] B = LC. Fun.Hash.AES_Encrypt (A, "#[email protected] $DJGJ #1a!2");            Textbox2.appendtext ("\ r \ n The total length of the encryption {1} time {0} seconds".) Formatwith (stopwatch. Elapsed.totalseconds, B.length));            Stopwatch. Reset (); Stopwatch. Start ();            Byte[] C = LC. Fun.Hash.AES_Decrypt (b, "#[email protected] $DJGJ #1a!2");            Textbox2.appendtext ("\ r \ n Decryption complete length {1} time {0} seconds".) Formatwith (stopwatch. Elapsed.totalseconds, c.length));            

  

[C #] How time-consuming to log programs

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.