JUNIT very slow.......

D

Dan

I have a small program I build as a stand-alone (i.e. as main method)
and as a junit test. I am using Apache Ant. When run as the Junit
test it takes bloody long time to ready itself before running -- on
the order of 1-2 minutes!! The total size of the library I am building
against is about 1.5M (class files).

I also see the available memory on my system going way down and
computer coming to a halt -- yuck. No such issues when run as a
standalone though -- runs as fast as I'd expect. My thought is that it
is not the inefficiency of my code but rather something Junit task is
doing internally. But maybe I am wrong.

Any thoughts on what is causing the long delay under Junit? Any way to
improve??

Thanks.
 
B

Bryce

I also see the available memory on my system going way down and
computer coming to a halt -- yuck. No such issues when run as a
standalone though -- runs as fast as I'd expect. My thought is that it
is not the inefficiency of my code but rather something Junit task is
doing internally. But maybe I am wrong.

Maybe its how you are setting up your test cases. What does your JUnit
class look like?
 
D

Dan

So after palying with the number of iterations taken in my program I
found that the time taken by Junit "getting started" is probably equal
to the total run time including time spent printing sending stuff to
std. output. But actually longer since avail. memory is going down
simulataneously. The issue with the memory going way down and system
slowing seems to be due to the fact that Junit is buffering all of the
standard output (I print a long of things to the terminal with
System.out.println). So maybe what is going on is that the Junit task
is running in a forked VM which can't dump its output to the standard
out until the Junit task completes. Does this sound likely? I've
tried various forkmodes in Ant's junit task but none seem to modify
this behavior.
This is obviously problematic way to run unit tests since as avaiable
memory is spent buffering output it is not available for running the
tasks. Any way to turn this behavior off?

I'll try to make a small/simple program reproducing such effects and
post if I can make it simple and standalone junit test. But if anyone
has any suggestions before then I'll try to implement.

Thanks.
 
M

Menno Holscher

Dan said:
simulataneously. The issue with the memory going way down and system
slowing seems to be due to the fact that Junit is buffering all of the
standard output (I print a long of things to the terminal with
System.out.println). So maybe what is going on is that the Junit task
I'll try to make a small/simple program reproducing such effects and
post if I can make it simple and standalone junit test. But if anyone
has any suggestions before then I'll try to implement.
JUnit is meant for on-line work with a programmer asking repeatedly to run
the tests associated with current development. So when it starts (i.e. the
online version) it wil scavenge all visible classes and reflect upon them
to find the tests. That may well be why your available memory hurries
downward and it takes so much time to initialize.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top