Results 1 to 6 of 6

Thread: Retrieving interval of time

  1. #1
    Join Date
    Dec 2009
    Posts
    211

    Retrieving interval of time

    Hello,
    I want to recover the amount of time doing in a particular program.
    So I use this:
    Code:
    long tm = (new GregorianCalendar()).getTimeInMillis();
    treatment ();
    tm = (new GregorianCalendar()).getTimeInMillis() - Time;
    Is there another less expensive method (without creating an object instance).

  2. #2
    Join Date
    Nov 2009
    Posts
    583

    Re: Retrieving interval of time

    Hello,
    You can try the following code:
    Code:
    long str = System.currentTimeInMillis();
    treatment ();
    System.out.System.out.println("Running Time:+(System.currentTimeInMillis()-str));
    Hope this will help you. If you have any more problem then do post back.

  3. #3
    Join Date
    Nov 2009
    Posts
    446

    Re: Retrieving interval of time

    Hello,
    Check out the following code
    Code:
    / / Get current time
        long str = System.currentTimeMillis();
        
        / / Do something ...
        
        / / Get time elapsed in milliseconds
        long elapsedTimeMillis = System.currentTimeMillis()-str;
        
        / / Get elapsed time in seconds
        float sts = elapsedTimeMillis/1000F;
        
        / / Get elapsed time in minutes
        float elapsedTimeMin = elapsedTimeMillis /(60* 1000F);
        
        / / Get elapsed time in hours
        float eth = elapsedTimeMillis /(60*60* 1000F);
        
        / / Get elapsed time in days
        float etd = elapsedTimeMillis /(24*60*60* 1000F);

  4. #4
    Join Date
    Nov 2009
    Posts
    335

    Re: Retrieving interval of time

    Hello,
    Why use GreporianCalendar is something quite compet me hungry and therefore memory, the simple class java.util.Date faisq quite the case:
    Code:
    long tm = (new Date()).getTime();
    treatment ();
    tm = (new Date()).getTime() - Time;
    Otherwise what is more expensive between the call to a static method of class System and the creation of an object type Date (assuming that the manufacturer conducts date if the same treatment at least one treatment very close relative System.currentTime to class ...) The difference must be in thousandths of seconds, which is in any case very inexpensive. I therefore see no reason why you say that the treatment of GregorianCalendar is very expensive?

  5. #5
    Join Date
    Nov 2009
    Posts
    333

    Re: Retrieving interval of time

    Hello,
    I would like to the above post, of course, you want to have a processing time to the millionth of a second. In any case, the measure of processing time is useful for treatment rather expensive so a difference of a few thousandths of a second is negligible. If you need any more help regarding this topic then please do post back and do not forget to post your error with the code.

  6. #6
    Join Date
    Dec 2009
    Posts
    211

    Re: Retrieving interval of time

    Hello,
    Thanks for you reply. It works great so the problem is RESOLVED. So thank you again (mostly for speed)
    The exact name of the method is:
    Code:
    long Time = System.currentTimeMillis();
    Not:
    Code:
    System.currentTimeInMillis ()
    If you guys know any other alternative for doing the same, then please do post back, it will help me a lot.

Similar Threads

  1. What is the importance of thermal paste and what is the time interval to change it?
    By Falgu in forum Overclocking & Computer Modification
    Replies: 9
    Last Post: 09-07-2012, 11:42 AM
  2. Replies: 6
    Last Post: 20-08-2011, 12:11 AM
  3. Replies: 7
    Last Post: 30-07-2011, 12:24 AM
  4. Replies: 4
    Last Post: 07-07-2011, 03:45 AM
  5. How to modify time interval in movie maker of Windows XP
    By Urvaksh in forum Windows Software
    Replies: 4
    Last Post: 04-01-2011, 08:27 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,273,948.68961 seconds with 17 queries