473,398 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Application is slow while writing data in to text files.

Hello,
I am having a performance issue with one of my C#.NET console application. The application is faster(takes 10 mins) when it runs from our test environment, but slower on Production environment(takes 80 mins). The settings/Configurations are same between the two environments.The application reads a text file, which has 180K records, and splits it up into multiple text file based on a condition. I am attaching the code with this. Please give your valuable suggestions and help me resolve this.
In the sample code, I have used stream writer to write in to files. I tried with File.AppendText, BinaryWriter etc. But no change in the performance.
Thanks
Attached Files
File Type: txt Sample.txt (3.0 KB, 444 views)
Jul 19 '10 #1
3 1969
Joseph Martell
198 Expert 128KB
I invite anyone to correct me if I am wrong, but when we start talking about access times for file reads/writes there are a lot of possible causes including hardware.

Are you using the same .Net framework version in test and production? How does your test hardware compare to your production hardware? Are you using a local disk in your test environment and not in production? If you are using a local disk in production, is the disk slower in production than in test? How busy is production as compared to test? Is your production server loaded down with other processes and services or are there any other processes which have a lot of file I/O accessing the same disk?
Jul 19 '10 #2
Thanks for your quick response. Both the servers have same same version of framework(2.0),OS,service packs installed. Both READ and WRITE operation is done on local disks on both the servers. Production server will be busy between 2 and 5 pm and this application is being executed in the morning. I don't see any other services, processes that do I/O operations or are memory/CPU expensive.
I checked with Infrastructure team and they said that both the servers are same in terms of hardware configuration and settings. I have no clue at all. Perhaps, Did i miss any settings in the application properties for it to run slower?

Thanks
Jul 19 '10 #3
Joseph

I am having similar problems writing to a server. I think we have hardware problems. But there seems to be a major bottleneck in allocating space in windows server for a new file or extending old ones. So I tried the following experiment.

I preallocated the space for the file. In the language I am using this means writing record number 180000 before record 1. This forces windows to allocate all the space needed for the file in one step. I then wrote 180000 records of 256 bytes each. It took two minutes! Letting Windows allocate the space as and when needed this exercise would have taken 480 minutes on the system we have.

If you found another solution I would be interested

Regards

Tony Grimshaw
Nov 26 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Thomas Bartkus | last post by:
Can anyone show an example MySQL command to import a text file into a table? I have a massive qty of data to get into a MySQL database on a server over the internet. Shouldn't I be able to do...
11
by: MM | last post by:
Hi I have never written any C programs before, but it seems that I need to do so now. Hope some of you out there can spend a few minutes and help me by writing a simple example of something...
12
by: Chris Springer | last post by:
I'd like to get some feedback on the issue of storing data out to disk and where to store it. I've never been in a production environment in programming so you'll have to bear with me... My...
1
by: svijay | last post by:
hi I have got a strange problem. May I know any solution for this. Here is the detailed description about the problem We have got a mainframe system and also production and development...
5
by: Alan Searle | last post by:
I am exporting ms-access data to XML files. This works fine. However, I need to insert one line at the top of each exported file (i.e. a reference to the XSL file) and am having a problem with...
6
by: Yi Xing | last post by:
Hi, I need to read specific lines of huge text files. Each time, I know exactly which line(s) I want to read. readlines() or readline() in a loop is just too slow. Since different lines have...
2
by: | last post by:
Hi, I have an idea that I want to write to many (qty unknown untill run time but in the order of 5) text files as my application runs. They're log files dealing with different aspects of the...
14
by: rafal_ | last post by:
Is difference between interpretation of \n only difference ?
0
by: smeltz101 | last post by:
I'm familiar with linecache.getline(filename, lineno). But what I was wondering was if it was possible to use a web address in place of the filename. So rather than C:/Webcontent/mytextfile.txt I...
2
by: as001 | last post by:
Hi, I'm writing a windows application in C# using VS 2003. I got stuck where it has to write multiple output text files. Here's my piece of code: for loop { Random r = new Random();...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.