Created
May 20, 2020 01:26
-
-
Save rfk/d058ee6d0528a16815be77c3b90cafa2 to your computer and use it in GitHub Desktop.
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
import sys | |
with open(sys.argv[1]) as f: | |
lines = (ln.strip() for ln in f) | |
# Skip headers. | |
assert next(lines).startswith("Lines") | |
assert next(lines).startswith("-----") | |
assert next(lines).endswith("(TOTAL)") | |
# Sum up serde-related things vs total. | |
totalLoC = 0 | |
serdeLoC = 0 | |
for ln in lines: | |
(loc, _, _, _, name) = ln.strip().split(None, 4) | |
totalLoC += int(loc) | |
if "serde" in name.lower(): | |
serdeLoC += int(loc) | |
# What's the damage? | |
print("{} of {} LoC ({:.2f}%) can be blamed on serde".format( | |
serdeLoC, | |
totalLoC, | |
(serdeLoC / totalLoC) * 100 | |
)) |
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
import sys | |
with open(sys.argv[1]) as f: | |
lines = (ln.strip() for ln in f) | |
# Skip headers. | |
assert next(lines).startswith("Lines") | |
assert next(lines).startswith("-----") | |
assert next(lines).endswith("(TOTAL)") | |
# Sum up serde-related things vs total. | |
totalLoC = 0 | |
serdeLoC = 0 | |
for ln in lines: | |
(loc, _, _, _, name) = ln.strip().split(None, 4) | |
totalLoC += int(loc) | |
if "serde" in name.lower(): | |
serdeLoC += int(loc) | |
# What's the damage? | |
print("{} of {} LoC ({:.2f}%) can be blamed on serde".format( | |
serdeLoC, | |
totalLoC, | |
(serdeLoC / totalLoC) * 100 | |
)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment