Created
November 3, 2018 07:15
-
-
Save Jul10l1r4/10d8ae6211950d353e652bcdd6b61875 to your computer and use it in GitHub Desktop.
Esse é um script que calcula a velocidade de várias formas de imprimir algum valor na tela, CLI. BashMetal 🤘
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 | |
# declarando variavel | |
buffer=""; | |
# sendo claro | |
echo "Teste de performance entre ECHO, PRINTF e CAT" | |
echo "Armazendo variáveis" | |
# fazendo o processador tremer | |
for i in $(seq 10000) | |
do | |
buffer+="@#$%%&*I&FDFSRWEGsy€®³®ŧŋđðđðŋæ" | |
done; | |
# realizando testes | |
function echoTest (){ | |
echo "$buffer" > /dev/null | |
} | |
function priTest (){ | |
printf "$buffer" > /dev/null | |
} | |
function printfTest () { | |
printf "$buffer" > "/dev/stdout" > /dev/null | |
} | |
function catTest (){ | |
cat <<- EOF > /dev/null | |
$buffer | |
EOF | |
} | |
# Saída do resultado | |
echo -e "\n### ECHO ###" | |
time echoTest | |
echo -e "\n### PRINTF ###" | |
time priTest | |
echo -e "\n### /dev/stdout ###" | |
time printfTest | |
echo -e "\n### CAT ###" | |
time catTest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment