Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is faster to read, ASCII or Binary?

I am presently working on a C++ project that involves reading in thousands of small (~20kb) text files which are all in ASCII format.

Will I be able to get a significant performance improvement by converting all of the files into Binary before analyzing them?

like image 733
Andy Avatar asked Nov 29 '22 04:11

Andy


2 Answers

Converting a string to a number, while not cheap in cpu cycles, is a non-issue. The amount of overhead involved with I/O is always orders of magnitude larger than the conversion. The size of the file is not much of an issue either, a disk supplies 8KB about as fast as 20KB, it all comes out of the same cluster on the same track. Having thousands of files is a big issue, opening a file involves moving the disk reader head and that takes forever.

So focus on whittling down the number of files for a real gain.

like image 117
Hans Passant Avatar answered Dec 04 '22 21:12

Hans Passant


There is no real difference between "ASCII" and "Binary" if you're handling text. ASCII is an interpretation of Binary data as text. So, if I understand your question correctly, the answer is no, there is no conversion that is possible and there is no performance improvement.

like image 41
OmnipotentEntity Avatar answered Dec 04 '22 23:12

OmnipotentEntity