Re: Pattern suggestion
On 04/15/2012 08:04 AM, Rui Maciel wrote:
FrenKy wrote:
Hi *,
I have a huge file (~10GB) which I'm reading line by line. Each line has
to be analyzed by many number of different analyzers. The problem I have
is that to make it at least a bit performance optimized due to sometimes
time consuming processing (usually because of delays due to external
interfaces) i would need to make it heavily multithreaded.
File should be read only once to reduce IO on disks.
So I need "1 driver to many workers" pattern where workers are
multithreaded.
I have a solution now based on Observable/Observer that I use (and it
works) but I'm not sure if it is the best way.
Well, we aren't either.
"Best" is a very loose term, and it encompasses multiple often
mutually-exclusive metrics. What is your metric for "best"?
How do you measure it?
Even after you answer that, we don't know. We haven't seen your code. You
might have a simply brilliant implementation of what you call
"Observable/Observer" that simply blows any other approach out of the water.
Conversely, your "Observable/Observer" label may be wildly inapplicable, and
the code utter crap, and even were that the correct pattern the execution
thereof might have barely crawled out of the crapper.
We simply don't know. You maybe have the best, worst or somewhere between of
all possible implementations. I hope it's nearer the first than the second.
Would you go to a nutritionist and say, "I'm on a high-carb diet, is that the
best way?" It might be, if the carbs are starchy like pasta and you're at the
shore running marathons. It might not be, if you're eating only Twinkies and
beer and watching your fourth straight /Jersey Shore/ marathon.
Tell you what. How about you share what you've done and then, based on
information, we provide feedback?
http://sscce.org/
--
Lew