Dear Sidds,
I don't know is there any direct methods to calculate
how much time taking to do a perticular task.
But still u can use ur own Timestamps inbetween ur
programming code to calculate the time ellapsed for
finish tht job.
Process flow for my example:-
1. Startup TimeStamp stored in a variable using new
Date().getTime() (new Date().getTime() will return the
current time in milliseconds since Jan 1, 1970 known
as "the epoch")
2. A Array with 10k elements intialized and unique
values are assigned for each element. It's not amazing
tht findining 10k values 10000k Random nos is not
enough to tick my time counter to high.
3. So i used one more for loop to sort the array &
finally i printed the MIN,MAX nos with appropriate
time Stamps.
hope this will hep u..
regards,
S.Vasanth Kumar.
import java.util.Date;
public class TimeCalc
{
public static void main(String args[])
{
long lngStart = new Date().getTime();
double dblRandom[] = new double[10000];
for(int i=0;i<10000;i++)
{
boolean flagDuplicate = true;
do
{
dblRandom[i] =
Math.round(Math.random()*10000000d);
flagDuplicate = false;
for(int j=0;j<i;j++)
{
if(dblRandom[i] == dblRandom[j])
{
flagDuplicate = true;
break;
}
}
}
while(flagDuplicate);
}
long lngArray = new Date().getTime();
System.out.println("Array created in " +
(lngArray-lngStart) + " milliseconds");
for(int i=0;i<dblRandom.length;i++)
{
for(int j=0;j<i;j++)
{
if(dblRandom[i]<dblRandom[j])
{
double dblTemp = dblRandom[i];
dblRandom[i] = dblRandom[j];
dblRandom[j] = dblTemp;
}
}
}
System.out.println("\t\tMin=" + dblRandom[0] + ",
Max=" + dblRandom[9999]);
System.out.println("Min,Max found in " + (new
Date().getTime()-lngArray) + " milliseconds");
System.out.println("Total Execution Time " + (new
Date().getTime()-lngStart) + " milliseconds");
}
}
--- sidds2k1 <[EMAIL PROTECTED]> wrote:
>
>
> hi all
> i have stuck in the problem ..actually i am creating
> an application
> it is taking so much time to display the page .i
> want to know
> actually how much time it is taking .is there any
> some methood
> through which i can know the time of my
> application..inmillesec . i
> have tried with system.millisec ()..but this is not
> working
> help
> siddharth
> [EMAIL PROTECTED]
>
>
>
>
>
>
>
________________________________________________________________________
Yahoo! India Matrimony: Find your partner online.
http://yahoo.shaadi.com/india-matrimony/
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/5cFolB/TM
--------------------------------------------------------------------~->
If you have any comments or questions, submit it on the message board.
NO spam/ads/job posting or you will be BANNED from this group. Exception can be made
it happen by notify me ahead of time.
all new members' message will be verified by me (spam..) before it get posted.
Yahoo! Groups Links
<*> To reply to this message, go to:
http://groups.yahoo.com/group/java_official/post?act=reply&messageNum=17273
Please do not reply to this message via email. More information here:
http://help.yahoo.com/help/us/groups/messages/messages-23.html
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/java_official/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/