Blog.

How to calculate size of your application

Have you ever been interested how many files your application consists of? Or how many lines have you and your developers have written in this app? Here is how to easily count them.

GNU find, cat and wc commands used below are installed on OS X and Linux by default.
Although the ports to Windows do exist, I have not tested them because I do not have a Windows computer with Ext project. Hence, I welcome comments from Windows users very much.

Calculate number of files

cd /your/project/dir
find -E app.js app ux overrides sass packages/mytheme \
    -regex '.*\.(js|scss)' | wc -l

This command descend to app, ux, overrides, sass and packages/mytheme directories to find JavaScript and Sass files.

If you have your sources in some additional directories just add them to the list, or remove theme directory from the list if you don’t use a custom theme. Similarly, if you want to count, for example, PHP files, add them to the list of extensions in the regex expression: -regex '.*\.(js|scss|php)'

The file names are then piped (|) to wc command – which, by the way, stands for “word count”, not for “water closet” – that with -l switch counts lines, in this case files.

The output is a single number giving you the number of files matching the find conditions. In one of the projects I’ve supervised recently it was 1047.

Calculate number of lines

It is very similar, we only need to concatenate the content of files before we pipe it to wc command. Thus:

cd /your/project/dir
find -E app.js app ux overrides sass packages/mytheme \
    -regex '.*\.(js|scss)' -exec cat {} \; | wc -l

Again, output is a single integer. In my case it was 146,206.

Feel free to post your results in comments.

saki
Follow me:
Latest posts by saki (see all)

One Response

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Enter your username and password to log into your account. Don't have an account? Sign up.

Want to collaborate on an upcoming project?