Hello!

I am writing a java program. This application will work on very slow computers too.

1) My application prints on the command line logs about what action did the user. Sometimes one action needs to write 50 lines on command line. Sometimes 2-3 lines... But these 50 lines are not inside a loop. Anyway, I am thinking to write a new method which will print on the screen the logs.

void cmd_write(String message)
{
   if( cmd_output == true )
   {
       System.out.println(message);
   }
}

I am thinking to call this method everytime when i need "printf". My application will start from command line by activating the command line output.

my_java_app.jar -cmd_output disabled

If they use my app by disabling this feature, my app will work better ( faster) ? Because it is going to call a method and it will compare two boolean values everytime. What do you think about?

2)Also, is it possible to test a program from eclipse like am working on a slow machine?

Thank you!

Recommended Answers

All 4 Replies

You could actually write this more concisely like this:

void cmd_write(String message)
{
    if( cmd_output )
        System.out.println(message);
}

Other than that, your application will run slightly slower because of the boolean comparison each time, but it isn't really significant in the grand scheme of things. The only major delay if you were printing out millions upon millions of lines would be that the text had to be drawn to the screen every time through your display server, but you can't control that from Java.

Overall you probably don't need to test things like they were on a slow computer if you are interacting with text. Heavy algorithms you might, but those are better written in a compiled language anyway.

- Joe

When you are talking about "slow" computer, what is the specification for that? Java also relies on memory (for JVM). So if you are talking about 486 with 66 MHz and 32 MB of RAM (I still have it tuck away in my attic :(), then it is still OK to display 50 lines of messages at a time on the console. But if you are talking about graphic, then this ancient may not work smoothly (or even stops and thinks for a long time before it displays).

When you are talking about "slow" computer, what is the specification for that? Java also relies on memory (for JVM). So if you are talking about 486 with 66 MHz and 32 MB of RAM (I still have it tuck away in my attic :(), then it is still OK to display 50 lines of messages at a time on the console. But if you are talking about graphic, then this ancient may not work smoothly (or even stops and thinks for a long time before it displays).

I'm talking about anything that can run a semi-modern OS, so, XP and above, say a P4 with 256 mb RAM and up. I don't think any modern Java will run on much less than that.

This should not work slow on the PC configurations you mentioned as this just a very basic program. Is this the entire program or is there any other calculations or looping done ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.