dart-lang / sdk
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 72,391 units with 841,939 lines of code in units (47.6% of code).
    • 575 very long units (91,480 lines of code)
    • 1,839 long units (124,839 lines of code)
    • 7,342 medium size units (225,205 lines of code)
    • 11,392 small units (165,822 lines of code)
    • 51,243 very small units (234,593 lines of code)
10% | 14% | 26% | 19% | 27%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
dart10% | 14% | 26% | 20% | 29%
cc13% | 18% | 30% | 19% | 18%
py9% | 14% | 29% | 22% | 23%
js13% | 11% | 27% | 25% | 22%
java0% | 27% | 19% | 17% | 35%
h0% | <1% | 4% | 12% | 82%
c0% | 0% | 16% | 7% | 75%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
pkg9% | 15% | 26% | 19% | 28%
runtime12% | 15% | 28% | 18% | 24%
benchmarks38% | 5% | 14% | 10% | 31%
sdk7% | 10% | 20% | 22% | 39%
tools9% | 14% | 27% | 22% | 26%
build0% | 22% | 33% | 23% | 20%
samples_20% | 17% | 16% | 27% | 38%
samples-dev0% | 1% | 29% | 27% | 41%
ROOT0% | 20% | 61% | 16% | 2%
utils0% | 0% | 40% | 45% | 13%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
Future compile()
in pkg/compiler/lib/src/dart2js.dart
882 146 2
ClassMembersNode build()
in pkg/front_end/lib/src/fasta/kernel/hierarchy/members_node.dart
794 202 0
ErrorPtr Object::Init()
in runtime/vm/object.cc
661 11 3
506 94 1
void generateHeader()
in pkg/front_end/tool/generate_ast_equivalence.dart
505 100 2
static ObjectPtr RawMatch()
in runtime/vm/regexp_interpreter.cc
492 57 5
bool FlowGraphInliner::TryInlineRecognizedMethod()
in runtime/vm/compiler/backend/inliner.cc
476 190 13
void Object::Init()
in runtime/vm/object.cc
441 1 1
void Simulator::DecodeSIMDDataProcessing()
in runtime/vm/simulator_arm.cc
439 256 1
void _buildFileDeclarations()
in pkg/analyzer/lib/src/services/available_declarations.dart
433 54 1
T read()
in pkg/compiler/lib/src/common/codegen.dart
416 66 1
MapLiteralEntry inferMapEntry()
in pkg/front_end/lib/src/fasta/kernel/inference_visitor.dart
412 58 11
void _writeTypeObject()
in pkg/analysis_server/tool/spec/codegen_java_types.dart
397 59 2
void _delegateRequest()
in pkg/vm_service/lib/src/vm_service.dart
393 64 1
static bool canParse()
in pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart
391 88 2
void _doParse()
in sdk/lib/_http/http_parser.dart
389 125 0
InvocationInferenceResult _inferInvocation()
in pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart
377 80 14
void _delegateRequest()
in pkg/vm_service/tool/dart/generate_dart.dart
366 59 1
static ServerCapabilities fromJson()
in pkg/analysis_server/lib/lsp_protocol/protocol_generated.dart
362 80 1
bool _isNullabilityAwareSubtypeMatch()
in pkg/front_end/lib/src/fasta/type_inference/type_constraint_gatherer.dart
356 131 3