thank you for the feedback, guys... i will go with the second method. before reading about benchmark, i timed the two methods using unix's time command. here are the results:
cat:
real 0.3
user 0.1
sys 0.2
read:
real 0.2
user 0.0
sys 0.1
Hi. Due to the small number of instructions executed, both scripts are too small for a trustable benchmark.
real measures how much time the program took to execute, user how much time took in user mode, and sys, how much in kernel mode.
Notice that your system may be busy, so there may be many processes changing their context.
This (which is part of the so called system entropy) may vary in a very short time, and as your scripts runs also for a very short period of time, entropy may affect them in different ways.
This may cause the fastest script to appear as the lowest.
Try to rewrite them opening a reasonable ammount of files, so you can compare times of execution more accurately.