codestats 1.0 is out! It's a command-line tool, written in Rust, that counts the code, comment, blank, and shebang lines in a codebase by language. My last post about it was for version 0.7.0, so there's a lot that's changed since then.
My goal for 1.0 was to make Codestats the fastest and most accurate code counter around. I've successfully done this, with numbers to proove it.
Speed, with every tool counting the same files on Linux:
- cpython: 18 ms. mezura takes 24, scc 51, and tokei 107.
- The Linux kernel, 63,738 files: 217 ms. mezura takes 238, scc 626, and tokei 1,106.
What's new since 0.7.0:
- cs diff compares line counts by language between git revisions.
- Code embedded in other languages is counted by its own language's rules: script and style elements in HTML, Vue, Svelte, and Astro, code blocks in Markdown, HTML in PHP, and more.
- Comment markers inside strings are ignored, Python docstrings count as comments, and heredocs, raw strings, and interpolated strings are read correctly.
- Generated files are detected by their headers and skipped by default.
- Linguist attributes in .gitattributes are respected.
- --git counts only the files git tracks.
- You can count several paths together, or read paths from standard input, as in git ls-files -z | cs -
- --ext counts only the extensions you ask for.
- It recognizes more than 560 languages, and detection is much better for extensions that several languages share, such as .h and .m.
- Starting with 1.0, JSON fields, CSV and TSV columns, and config file keys only change in a new major version.
Prebuilt binaries for Linux, macOS, and Windows are on GitHub, each for x86-64 and ARM64. You can also run cargo install codestats, but the prebuilt binaries are faster because they use profile-guided optimization.
#Rust #RustLang #OpenSource #CommandLine