|
-
April 17th, 1999, 02:29 PM
#1
performance of fstream in C++
Hi there,
Could anyone tell me which is faster to save data with fstream---
Situation: A line of text containing many segment are to be stored to a file, for example: Bob Is Cool.
Methods:
(1) Use fstream and output one word a time. Like
out << "Bob ";
out << "Is ";
out << "Cool.";
(2) Use fstream and output the whole sentence at one. Like
out << "Bob Is Cool.";
Which method is faster? Thanks for help.
-
April 17th, 1999, 04:03 PM
#2
Re: performance of fstream in C++
2 is likely to be faster, but there probably isn't as much difference in it as you might expect. Method 1 is unlikely to cause a disk seek on each line because in both 1 and 2 it's all memory cached until something causes the file to be flushed. So the difference is memory allocation and function call overhead, not disk hardware times.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|