Sample Header Ad - 728x90

Why creating files in /dev/shm is not faster than creating files in /tmp?

3 votes
1 answer
1599 views
Let's say I have two bash files. The first one is called diskFile.bash:
for i in {1..10000}
do
	file=$(mktemp)
	cat > $file  $file <<- "SIGN"
		"Hello World"
SIGN
done
echo "finished"
On Linux, files created inside /dev/shm are files inside the RAM memory of the system. But if I try executing the first file with time bash diskFile.bash, I get:
finished
15.56user 5.74system 0:20.25elapsed 105%CPU (0avgtext+0avgdata 6324maxresident)k
And with time bash ramFile.bash:
finished
15.20user 5.37system 0:19.45elapsed 105%CPU (0avgtext+0avgdata 6380maxresident)
The difference of time doesn't look like a significant one considering /dev/shm should be using RAM memory. Why creating temporary files inside /dev/shm is not faster than creating temporary files inside /tmp? Is there any way of speeding up the process of creating files using bash?
Asked by raylight (531 rep)
Mar 22, 2022, 03:28 PM
Last activity: Nov 27, 2023, 08:35 PM