tensorflow / tpu
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 2,519 units with 49,923 lines of code in units (64.8% of code).
    • 41 very long units (6,151 lines of code)
    • 158 long units (10,739 lines of code)
    • 573 medium size units (18,336 lines of code)
    • 557 small units (8,308 lines of code)
    • 1,190 very small units (6,389 lines of code)
12% | 21% | 36% | 16% | 12%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py13% | 21% | 36% | 17% | 11%
c8% | 21% | 42% | 16% | 11%
go0% | 21% | 41% | 11% | 24%
h0% | 11% | 0% | 18% | 69%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
models/official13% | 22% | 37% | 16% | 11%
models/experimental19% | 19% | 31% | 18% | 11%
tools/driver7% | 20% | 39% | 16% | 15%
tools/ctpu0% | 21% | 41% | 11% | 24%
models/hyperparameters0% | 37% | 9% | 30% | 22%
tools/datasets0% | 20% | 32% | 28% | 17%
tools/data_converter0% | 11% | 41% | 22% | 24%
models/common0% | 0% | 72% | 19% | 8%
tools/diagnostics0% | 0% | 0% | 83% | 16%
tools/dataset_profiler0% | 0% | 0% | 67% | 32%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def main()
in models/official/retinanet/retinanet_main.py
395 67 1
def inception_v2_base()
in models/experimental/inception/inception_v2_tpu_model.py
389 24 6
def _model_fn()
in models/official/mask_rcnn/mask_rcnn_model.py
211 53 5
def build_model_fn()
in models/official/mnasnet/mnasnet_main.py
184 47 4
def __call__()
in models/official/detection/projects/vild/modeling/vild_head.py
176 38 3
def inception_model_fn()
in models/experimental/inception/inception_v3.py
174 27 4
def main()
in models/official/resnet/resnet_main.py
171 14 1
def build_model_graph()
in models/official/mask_rcnn/mask_rcnn_model.py
171 27 4
def main()
in models/official/efficientnet/main.py
170 23 1
def resnet_model_fn()
in models/official/resnet/resnet_main.py
167 46 4
def inception_model_fn()
in models/experimental/inception/inception_v4.py
164 26 4
def model_fn()
in models/official/efficientnet/main.py
159 41 4
def parser_generator()
in models/official/detection/dataloader/factory.py
159 11 2
def main()
in models/official/mnasnet/mnasnet_main.py
157 17 1
def inception_model_fn()
in models/experimental/inception/inception_v2.py
154 19 4
def _create_dataset_parser_fn()
in models/official/mask_rcnn/dataloader.py
152 23 2
def main()
in models/official/resnet/benchmark/resnet_benchmark.py
138 15 1
def multilevel_crop_and_resize()
in models/official/detection/ops/spatial_transform_ops.py
135 12 4
def main()
in models/official/retinanet/retinanet_segmentation_main.py
134 9 1
def main()
in models/official/mobilenet/mobilenet.py
132 21 1