3

I've often found the debug mode of Eclipse useful over relying on print statements or logging. However, I've found that the debug mode's performance seems to be particularly sensitive to file I/O. Loading a file can be way slower (taking ~25 times as long), and since my workflow requires loading a rather large file before I get to anything interesting, this is particularly inconvenient for me.

Is there any sensible workaround for this issue? I don't actually need the debugging during the file loading part, so is there perhaps a way to only jump into debug mode at a certain point in the process?

Note that, unlike this question, I do not believe this is a problem with the state of my workspace.

Community
  • 1
  • 1
Michael McGowan
  • 6,528
  • 8
  • 42
  • 70

2 Answers2

2

You can hook into a running application with eclipse's remote debuging feature. You have to start your app with some parameters:

java -Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y suspend=y -jar yourapp.jar

Then in your debug configuration choose Remote Java Application using port 8001.

More detailed with pics here

nansen
  • 2,912
  • 1
  • 20
  • 33
1

It's possible you're doing IO in a slow way (reading in small pieces), and debugging is just amplifying that, since there's overhead for every function call.

NetBeans has a way to specify which functions to profile, so I'd look for a similar option in Eclipse, and then tell it not to profile anything in the java.* namespace, or any of your IO specific code if that doesn't help.

I'd also make sure you're reading your file in a fast way (using buffered input streams, not using Scanner, etc.). There may also be things in NIO that could help, but I'm not that familiar with it.

Brendan Long
  • 53,280
  • 21
  • 146
  • 188
  • This doesn't really help me. The IO's performance is fine when not debugging, and I'm not interested in micro-optimizing it now as it's good enough and I have more important concerns. I'm not using NetBeans, and obviously if I could find such an option in Eclipse then I wouldn't have asked this question. – Michael McGowan Mar 23 '12 at 19:04