• Post Reply Bookmark Topic Watch Topic
  • New Topic

Wish to avoid frequent I/O operations

 
Mahesh Bamane
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have been generating some report based on two i/p files(.txt format).
This is standalone java program. so each time i run the program i have to read both the files every time thats i/o overhead.
Same happens in the case of properties file also. Is it possible that somehow I could avoid these operation every time.
Is it feasible to use serialization?
Correct me if i am wrong.
Please advise.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this program has no parts that are continuously running, then reading that data from some kind of storage is unavoidable.
But have you actually determined that there is a performance problem, and that it is caused by the reading of the files? If not, then that should be the first step before attempting any optimizations.

Serialization would also involve file I/O, and uses reflection which is not too fast a process. So it's not immediately clear that anything is to be gained that way. It might be, if there's complex processing associated with those files that can be avoided by storing objects directly. But you really need to find out first where any perceived slowness is coming from, file I/O or processing or something else.

By the way, is reading two files at the start of a desktop app really "frequent I/O"?
 
Mahesh Bamane
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, Reading file at the start of the desktop appn. is definitely not a frequent I/O.
But from one of the file I am reading thousands of rows of data and storing each row in an object.
And there is a bit complex processing.
So i just wanted to ask will it be feasible to make that object serializable and i can read the data from that object whenever i run the program next time instead of reading it from file.
It may sound weird in desktop application but i want to read the files only when the program runs 1st time.
From next time onwards i can use the serialized object.

Please advise correct me if am talking non-sense
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You missed the main point of my post, which was: Do you have an actual problem, or is this just a gut feeling that things could (or should) be faster? Such gut feelings frequently turn out to be incorrect, and need to be replaced by actual measurements of what is and is not taking up noticeable time.

Also, the app needs to get its data from *somewhere* (in whichever shape the data may be in), so accessing a file or a DB is unavoidable.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could have written a test case and found out the answer with real numbers - much preferable to speculations.

I have found that object serialization and deserialization can be quite fast.

Making your objects Serializable might also help in later evolution of your application.

Bill
 
Mahesh Bamane
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf,

Answer your question Do you have an actual problem, or is this just a gut feeling that things could (or should) be faster?
is yes its a gut feeling, I know these operations we can nt avoid.
But am looking for an alternative, though the difference won't be too big.
Anyway thanks for your comments it is better to see the difference by actual implementation.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12342
39
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before doing anything, you should find out where your program really IS slowing down. You may spend hours refactoring your I/O, and never gain anything. Whereas if you profiled your code and found where the actual slowdown is, a 10 minute change could double your speed.

You just don't know until you do the profiling.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!