Skip to content

Instantly share code, notes, and snippets.

@rfk
Created May 20, 2020 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfk/d058ee6d0528a16815be77c3b90cafa2 to your computer and use it in GitHub Desktop.
Save rfk/d058ee6d0528a16815be77c3b90cafa2 to your computer and use it in GitHub Desktop.
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
))
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