• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

quick JAVA question!

gopunk

Lifer
what does it mean when your program terminates with something like this:

18.510u 0.030s 0:18.63 99.5% 0+0k 0+0io 1587pf+0w


this is clearly the result of the "time" command, but i don't know why it would be displaying this. it's a really simple loop that just increments from 0 by 1 until it reaches N. i set N to be 1,000,000,000. for smaller values like 10,000,000, it does not do this.

thanks 🙂
 
class Loop1
{
public static void main(String[] args)
{
int sum = 0;
int max = Integer.parseInt(args[0]);
long otime = System.currentTimeMillis();
for(int i=0; i < max; i++)
{
sum++;
}
long ntime = System.currentTimeMillis();
System.out.println(ntime - otime);
}
}

take it easy, i'm a java newbie 😛

as you can see, this program just returns an approximate running time in milliseconds. the time output i showed you earlier is not part of the ntime-otime stuff.



and here are my runs:

fiji% java Loop1 12000000
220
fiji% java Loop1 20000000
398
fiji% java Loop1 30000000
542
fiji% java Loop1 40000000
725
fiji% java Loop1 60000000
1082
fiji% java Loop1 70000000
1423
fiji% java Loop1 80000000
1472
fiji% java Loop1 90000000
1618
fiji% java Loop1 1000000000
17857
18.510u 0.030s 0:18.63 99.5% 0+0k 0+0io 1587pf+0w

the last one is the one i'm talking about here... notice how none of the other ones have the extra stuff.
 
hmm... it runs fine on my machine, what platform are you running on? and what version of the Java Runtime Environment are you using?
 
Originally posted by: Yomicron
hmm... it runs fine on my machine, what platform are you running on? and what version of the Java Runtime Environment are you using?

fiji% java -version
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)
fiji% uname -srv
Linux 2.4.18-6smp.1 #10 SMP Tue Sep 24 12:13:28 PDT 2002


i think it is something to do with csh or something.... check this out:

fiji% bash
bash-2.05a$ java Loop1 1000000000
17858
bash-2.05a$ exit
exit
18.570u 0.060s 0:54.76 34.0% 0+0k 0+0io 1953pf+0w
 
Originally posted by: notfred
No idea, looks like a bug in the currentTimeMillis method. Either that or an overflow or something.

yea i'm thinking it's something like that.... drat. oh well, not my box 😀

Originally posted by: Ameesh
waht does this have to do with java? its your loonicx box thats outpputting the process stats.

yea, you're probably right.
 
Back
Top