DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   How to get total time of running program (http://www.daniweb.com/forums/thread79053.html)

eena75 May 23rd, 2007 12:01 am
How to get total time of running program
 
Hai,
I write a simulation and need to set the time for running the simulation. the simulation should stop based on the time that heve been set .How to set start time, get the current time and lastly to get the total time of java running program? really hope u can help me asap :)

thekashyap May 23rd, 2007 6:52 am
Re: How to get total time of running program
 
So what have u tried so far.. ?
Post the code you've done..

jwenting May 23rd, 2007 2:56 pm
Re: How to get total time of running program
 
1) we don't do your homework for you, show some effort
2) we're certainly not going to let you order us around to do it "asap". If and when we do anything it'll be at a time and place of our choosing, not yours, suggesting anything else makes us LESS eager to help you.
3) (general warning) it's NOT "urgent" to anyone except possibly you, and if it is you should have started sooner.
4) properly define your problem domain. WHAT do you want to measure exactly? What that is defines where and how to measure it.

babyfrostie Jan 11th, 2008 6:44 am
Re: How to get total time of running program
 
can someone teach me how to get the running time of this program?
import java.io.*;
public class ArrauSample {

  public static void main(String args[]){
         
          BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
          int x=0;
          int max= 5;
         
        int myNum[] = new int[max];
        String myString[] = new String[max];
         
          try{
                  for(x=0; x<max; x++)
              {
                  System.out.println("Input element #" + (x+1));
                myString[x]=console.readLine();       
              }
          }catch(IOException e){}
         
          for(x=0; x<max; x++)
              {
                  System.out.print("Element #" + (x+1));
              System.out.println(myString[x]);
                              }

         
  }
   
   
}
thank you very much!

mickinator Jan 11th, 2008 7:42 pm
Re: How to get total time of running program
 
Well the basic way of getting time in a program is to use

long x = System.getCurrentTime();

which returns the current time of the computer in milliseconds.

Anyone with a brain could figure it out from there! :p

babyfrostie Jan 11th, 2008 10:53 pm
Re: How to get total time of running program
 
ammm we should compute it with our hands lol..

mickinator Jan 12th, 2008 4:56 pm
Re: How to get total time of running program
 
ive an abacus if you want one

bugmenot Jan 12th, 2008 6:10 pm
Re: How to get total time of running program
 
Quote:

Originally Posted by mickinator (Post 508762)
Well the basic way of getting time in a program is to use

long x = System.getCurrentTime();

which returns the current time of the computer in milliseconds.

Anyone with a brain could figure it out from there! :p

there is no such method in my Java API

perhaps you are thinking of System.currentTimeMillis()

mickinator Jan 12th, 2008 7:30 pm
Re: How to get total time of running program
 
Lol, my mistake, thats it right there.


All times are GMT -4. The time now is 8:58 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC