Hi,
I have blank in this type of question. Suppose i have an 100 records in my sql database. i am creating 100 files for each records (100 records) in 10 min. Now I want to create 200 files in same 10 minutes. Means double files in same time.

how i can do this.


Thanks in advance.............

First question I have to ask is what is taking you so long to create the files? I just ran a test and was able to create 10,000 files in less than 4 seconds.

Hi,Momerath its just logic testing question not the performance testing.

So can u tell me the logic to how to do this.

Momerath had to point. What does it take so much to co create 100 files?
Next - if your code (and computer) is capable of 100 per 10 minutes, then this is it! You actually cant make the same files two times faster.

Would you mind showing us the code you got there? Maybe we can figure something out.
And tell us your logic about fasering the procedure of file creation.

Actually this question was ask for the interview purpose. so i have no idea about logic here. is their is any solution to create double files in same time.

I'll go out on a limb here and say this is something to do with testing your threading ability/logic.

Although implausible to reduce the time by 50%, if you had 2 threads writing the data (say thread 1 does all odd records and thread 2 does all even records) this *could* (depends on the bottleneck) grant you faster file creation.

Without knowing what part of the hypothetical application is performing the worst, it's hard to make decisions about where you need to improve it.

File creation is IO bound (on any system running today) and not CPU bound. To double the speed of creating files you'd have to write files to different IO channels, for example, writing to two different drives.

File creation is IO bound (on any system running today) and not CPU bound. To double the speed of creating files you'd have to write files to different IO channels, for example, writing to two different drives.

You're assuming he's IO bound to the write drive. There could be any number of bottlenecks in the middle, including seek/wait time from the database, IO delay, read/write loops etc. Hence why it's impossible really to suggest the single way to do it when you have no information.

Threading would be one way to do it. Read with one thread and write with another at the same time, then reverse roles etc. That should keep up a constant flow of data rather than it sitting around waiting for either the IO system or the database. (Think of it as a basic version of pre-buffering)

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.