Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Test and Performance Tools Platform (TPTP) » Same code but 10 times the base time
Same code but 10 times the base time [message #134994] Tue, 26 August 2008 10:17 Go to next message
Kent Tong is currently offline Kent Tong
Messages: 8
Registered: July 2009
Junior Member
Hi,

I was wondering if it is normal for two identical pieces of code
to have 100 times difference in their base times. For example,
in the code below:

public class Foo {
public static void main(String[] args) {
new Foo().m1();
}

private void m1() {
for (int i = 0; i < 10000; i++) {

}
Bar b = new Bar();
b.m2();
}

}

public class Bar {

public void m2() {
for (int i = 0; i < 10000; i++) {
}
}

}

The m1() has a base time of 0.0299 while m2() has 0.000384. Running it
a few times makes no significant impact.
Re: Same code but 10 times the base time [message #135007 is a reply to message #134994] Tue, 26 August 2008 10:23 Go to previous messageGo to next message
Kent Tong is currently offline Kent Tong
Messages: 8
Registered: July 2009
Junior Member
Never mind; found the problem: It's "new Bar()" that is taking up the time.
Re: Same code but 10 times the base time [message #135032 is a reply to message #134994] Tue, 26 August 2008 11:42 Go to previous message
Vincent MAHE is currently offline Vincent MAHE
Messages: 129
Registered: July 2009
Senior Member
Kent Tong a écrit :
> Hi,
>
> I was wondering if it is normal for two identical pieces of code
> to have 100 times difference in their base times. For example,
> in the code below:
>
> public class Foo {
> public static void main(String[] args) {
> new Foo().m1();
> }
>
> private void m1() {
> for (int i = 0; i < 10000; i++) {
>
> }
> Bar b = new Bar();
> b.m2();
> }
>
> }
>
> public class Bar {
>
> public void m2() {
> for (int i = 0; i < 10000; i++) {
> }
> }
>
> }
>
> The m1() has a base time of 0.0299 while m2() has 0.000384. Running it
> a few times makes no significant impact.
>
>
May be the "new Bar()" induces a kind of context change into the JVM?

Vincent
Previous Topic:Using threadprof profiler crashes my JVM
Next Topic:no http requests recorded
Goto Forum:
  


Current Time: Wed Sep 17 01:35:17 GMT 2014

Powered by FUDForum. Page generated in 0.12124 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software