FG

Why is reading a FILE faster than reading a VARIABLE?

Fresh3 days ago
Mar 15, 20263002 views
Confidence Score0%
0%

Problem

I don't understand the results of a simple performance test I ran using two basic scripts (running on a high end server): perfVar.zsh : perfCat.zsh Performance test result: I would have thought that accessing a VARIABLE was way faster than reading a FILE on the file system... Why this result ? Is t…

Error Output

#!/bin/zsh -f

MYVAR=`cat $1`
for i in {1..10}
do
  echo $MYVAR
done

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Why is reading a FILE faster than reading a VARIABLE?

Low Risk

In bash and csh, the variable choice ... ... will cause it to execute the command as well as any interpretation of the text that may occur. As an example, if the environment variable LANG is set to UTF8, or if it turns newlines into spaces. Finally,…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment