0

Using for example C++ ofstream class http://www.cplusplus.com/reference/fstream/ofstream/

If I open a file for append:

std::ofstream myOutputFile;
myOutputFile.open("/tmp/mytest.txt", ios::out | ios::app);
myOutputFile << "This is a line\n";
myOutputFile.close();
  • Does the execution time depends on the file size?
  • Does it depends on the OS I'm running the program?
  • Does it depends on the File System type where I'm writing?

Let me rephrase:

When running this program multiple times on RH Linux 5.9 with Ext3 File System, does the execution time increases with the number of times this program has run (please have in mind the file size increases with each execution)?

Same question but with W7 Professional on NTFS File System?

My observation is that on RH Linux we have constant time and on W7 the execution time increases (I made the test with millions of iterations), but I don’t know if there is any additional variable that might influencing the results.

JoPaGo
  • 11
  • 2
  • Probably impossible to answer--nobody can say much of anything with certainty about every possible file system on every possible operating system ever invented. That said: it'll normally be at least close to constant time on most typical systems. There will be variations, but in most cases there variation will be nearly independent of file size. – Jerry Coffin Jun 06 '14 at 20:57
  • Related: http://stackoverflow.com/questions/21200264/ – Nemo Jun 06 '14 at 21:44

1 Answers1

0

File size: Maybe. File systems typically have random access, so it shouldn't.

OS: Yes. (pocket calculator vs database warehouse?)

File system: Yes. (NFS vs SSHFS vs FAT on floppy)

Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084