+ 1

Which is faster/more efficient? Retrieving information

I'm moving into 2nd year as a programmer. I know pretty much what there is to know about fundamentals and how to program what I want. I'll be learning methods and concepts this coming year with what I know. But as I was messing around with a program I was making, I wanted to know: Is it faster/efficient to have your computer retrieve information by: >importing another file and read it's characteristics from there? >opening a text file or binary file once and have the information in an array with records

10th May 2017, 1:28 AM
Sapphire
1 ответ
+ 2
I'm fairly sure that it would be situational. You'll have more overhead reading the file all at once, but it would allow the rest of your code to run unimpeded by the communications lag of repeatedly accessing the file (assuming you have sufficient RAM to hold everything you need). For large files, you'll have no choice but to read in pieces to avoid bogging down your program from lack of memory. This is the kind of trade-off that many institutions deal with, and is an active topic of research (spawning things like parallel processing and high data rate drives). All that chatter aside, I think that could make for an interesting and informative project (assuming you have the spare time).
10th May 2017, 2:53 AM
Jim
Jim - avatar