get_metrics: rewrite in Python, refactor output a bit

The script has gotten slow because of the test authors check.
It feels like the # of test files (i.e. inputs to git log) causes the
time to explode.

In commit, 82a75278c4c6 (" use git-grep to cut runtime by
>70%"), I'd reduced the overall script runtime to 9s. Now it's more
like 20s :(

We'll probably need to do some more clever tricks to make this more
bearable as KUnit grows, so let's use a real programming language.

This change also
* changes output order to print the slow test authors result last
* makes sure we exclude internal contributors from contributor count,
  not just the contribution patch count.
* no longer assumes we're running the script from inside the Linux tree
  (probably using it from your checkout of this repo)

$ <path>/ | ts -s '%M:%.S'
00:17.747701 Unique contributors:       35
00:17.747838 Number of patches: 73
00:17.747866 Number of total tests:     55
00:17.747879 Number of test authors:    93
00:17.747891 Number of test cases:      494

$ python3 -u <path>/ | ts -s '%M:%.S'
00:04.278519 Number of test cases: 494
00:04.278704 Number of patches: 73
00:04.278722 Unique contributors: 30
00:04.278733 Number of total tests: 55
00:15.614618 Number of test authors: 93

I.e. we get most of the results within 4s and also see some small speed
benefits to doing our output processing in Python.

Signed-off-by: Daniel Latypov <>
Change-Id: Iffb2baf2294bc4f56e3739b50e1ac4ea45a13e6b
2 files changed
tree: 942ee6714f678636fe06c2d2ae4f4ac3536e584b
  1. development/
  2. statics/
  3. third_party/
  4. usage/
  5. .gitignore
  10. index.rst
  12. Makefile
  13. mocking.rst
  14. press.rst
  16. release_notes.rst

KUnit Documentation

KUnit is a lightweight unit testing and mocking framework for the Linux kernel. These tests are able to be run locally on a developer’s workstation without a VM or special hardware.

KUnit is heavily inspired by JUnit, Python’s unittest.mock, and Googletest/Googlemock for C++. KUnit defines a way to mock out C style classes and functions and create expectations on methods called within the code under test.

This is a repository to host the source for the KUnit documentation.

NOTE: There is an important distinction between KUnit‘s documentation source and it’s documentation site. As a project meant primarily to serve the development of the Linux kernel, a significant portion of our code and documentation reside in the Linux kernel codebase. Consequently, the documentation that does not live in the Linux kernel follows many of the conventions of the Linux kernel. One of these conventions is that we use Sphinx for all of our documentation. Thus, because Sphinx requires documentation to be compiled from its source files, we must have a repository for all the Sphinx source files and a separate repository for all of the generated output files to actually host the site. This is the repository for the source.

Where is the code?

How to build documentation

Documentation can be built by running:

make html

How to update the documentation

Our documentation is hosted at The documentation may be updated by building the documentation as described above, and then:


You can copy the files over without committing and pushing the files with:

./ --no-commit