Created
November 21, 2018 19:48
-
-
Save Jul10l1r4/ca98011f88bc2ae49aa925450b0e7373 to your computer and use it in GitHub Desktop.
É um teste de loop em diferentes funções afim de verificar a performance de cada.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo """ | |
################################################## | |
Verificação de varias chamadas a mesma funcao | |
""" | |
loopado='Sou mais rápido!' | |
function echoLoop (){ | |
for a in `seq 1024` | |
do | |
echo "$loopado" > /dev/null | |
done | |
} | |
function prinLoop (){ | |
for b in `seq 1024` | |
do | |
printf "$loopado" > /dev/null | |
done | |
} | |
function prinThereLoop (){ | |
for c in `seq 1024` | |
do | |
printf "$loopado" > /dev/stdout > /dev/null | |
done | |
} | |
function catLoop (){ | |
for d in `seq 1024` | |
do | |
cat <<- EOF > /dev/null | |
$loopado | |
EOF | |
done | |
} | |
echo -e "--------------------------------------------------\n### PRINTF ###" | |
time prinLoop | |
echo -e "--------------------------------------------------\n### ECHO ###" | |
time echoLoop | |
echo -e "--------------------------------------------------\n### printf > /dev/stdout ###" | |
time prinThereLoop | |
echo -e "--------------------------------------------------\n### CAT ###" | |
time catLoop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment