1,105,331 Community Members

How to get total time of running program

Member Avatar
eena75
Newbie Poster
1 post since May 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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 :)

Member Avatar
thekashyap
Practically a Posting Shark
809 posts since Feb 2007
Reputation Points: 193 [?]
Q&As Helped to Solve: 77 [?]
Skill Endorsements: 0 [?]
 
0
 

So what have u tried so far.. ?
Post the code you've done..

Member Avatar
jwenting
duckman
8,359 posts since Nov 2004
Reputation Points: 1,399 [?]
Q&As Helped to Solve: 447 [?]
Skill Endorsements: 35 [?]
Infraction Points: 5
Team Colleague
 
0
 

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.

Member Avatar
babyfrostie
Light Poster
39 posts since Oct 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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!

Member Avatar
mickinator
Junior Poster in Training
55 posts since Oct 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
babyfrostie
Light Poster
39 posts since Oct 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

ammm we should compute it with our hands lol..

Member Avatar
mickinator
Junior Poster in Training
55 posts since Oct 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
0
 

ive an abacus if you want one

Member Avatar
bugmenot
Posting Whiz in Training
223 posts since Nov 2006
Reputation Points: 25 [?]
Q&As Helped to Solve: 34 [?]
Skill Endorsements: 0 [?]
 
0
 

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()

Member Avatar
mickinator
Junior Poster in Training
55 posts since Oct 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 5 [?]
Skill Endorsements: 0 [?]
 
0
 

Lol, my mistake, thats it right there.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article