Skip to content

Instantly share code, notes, and snippets.

@miladoll
Created September 9, 2020 07:42
Show Gist options
  • Select an option

  • Save miladoll/914b8d0b85e0bdd257345dfc18032db1 to your computer and use it in GitHub Desktop.

Select an option

Save miladoll/914b8d0b85e0bdd257345dfc18032db1 to your computer and use it in GitHub Desktop.
bashではstatを使うよりwc -cでPOSIX準拠にファイルサイズを取得したほうが速かったっぽい
$ ls -l test.jpg
-rwxrwxrwx 1 hoge hoge 756448 Sep 9 13:36 test.jpg
$ time ( for i in `seq 10000`; do wc -c test.jpg > /dev/null;done )
real 0m14.854s
user 0m4.216s
sys 0m4.275s
$ time ( for i in `seq 10000`; do stat -c%s test.jpg > /dev/null;done )
real 0m18.041s
user 0m4.050s
sys 0m4.676s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment