apple / swift-llbuild
Unit Size

The distribution of size of units (measured in lines of code).

Intro
  • Unit size measurements show the distribution of size of units of code (methods, functions...).
  • Units are classified in four categories based on their size (lines of code): 1-20 (small units), 20-50 (medium size units), 51-100 (long units), 101+ (very long units).
  • You should aim at keeping units small (< 20 lines). Long units may become "bloaters", code that have increased to such gargantuan proportions that they are hard to work with.
Learn more...
Unit Size Overall
  • There are 8,587 units with 62,996 lines of code in units (46.3% of code).
    • 22 very long units (4,228 lines of code)
    • 104 long units (6,932 lines of code)
    • 436 medium size units (13,264 lines of code)
    • 815 small units (11,862 lines of code)
    • 7,210 very small units (26,710 lines of code)
6% | 11% | 21% | 18% | 42%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
cpp12% | 19% | 25% | 17% | 25%
py27% | 8% | 17% | 8% | 37%
inc6% | 10% | 34% | 26% | 22%
h0% | 1% | 11% | 17% | 69%
cc0% | 5% | 36% | 29% | 29%
swift0% | 10% | 14% | 25% | 49%
c0% | 0% | 48% | 33% | 17%
mm0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
lib9% | 15% | 22% | 17% | 34%
utils3% | 2% | 28% | 28% | 36%
include0% | 1% | 7% | 12% | 77%
products0% | 5% | 21% | 25% | 47%
unittests0% | 6% | 14% | 16% | 62%
experimental0% | 42% | 0% | 21% | 35%
bindings0% | 0% | 0% | 11% | 88%
perftests0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
int llvm::sys::unicode::foldCharSimple()
in lib/llvm/Support/UnicodeCaseFold.cpp
541 283 1
int commands::executeNinjaBuildCommand()
in lib/Commands/NinjaBuildCommand.cpp
474 111 1
void llbuild::basic::spawnProcess()
in lib/Basic/Subprocess.cpp
367 52 9
251 24 1
bool CommandLineParser::ParseCommandLineOptions()
in lib/llvm/Support/CommandLine.cpp
232 76 4
bool isPrintable()
in lib/llvm/Support/Unicode.cpp
189 3 1
bool executeTasks()
in lib/Core/BuildEngine.cpp
188 38 1
bool parseCommandsMapping()
in lib/BuildSystem/BuildFile.cpp
169 35 1
def action_analyze()
in utils/ptreetime/ptreetime.py
168 12 2
bool open()
in lib/Core/SQLiteBuildDB.cpp
159 22 1
static void dumpNinjaManifestJSON()
in lib/Commands/NinjaCommand.cpp
150 36 2
int main()
in utils/adjust-times/adjust-times.cpp
140 37 2
void IEEEFloat::toString()
in lib/llvm/Support/APFloat.cpp
138 45 4
std::string Triple::normalize()
in lib/llvm/Support/Triple.cpp
137 53 1
std::string statusLinePrefix()
in lib/Commands/NinjaBuildCommand.cpp
127 33 1
StringRef ScalarNode::unescapeDoubleQuoted()
in lib/llvm/Support/YAMLParser.cpp
126 41 3
static bool Execute()
in lib/llvm/Support/Windows/Program.inc
125 24 7
static void dumpNinjaManifestText()
in lib/Commands/NinjaCommand.cpp
120 25 2
def _parse_event_log()
in utils/ptreetime/ptreetime.py
111 22 1
static void KnuthDiv()
in lib/llvm/Support/APInt.cpp
108 25 6