tensorflow / examples
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 491 units with 6,042 lines of code in units (75.7% of code).
    • 1 very long units (149 lines of code)
    • 10 long units (647 lines of code)
    • 74 medium size units (2,103 lines of code)
    • 113 small units (1,617 lines of code)
    • 293 very small units (1,526 lines of code)
2% | 10% | 34% | 26% | 25%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py2% | 10% | 34% | 26% | 25%
kt0% | 0% | 44% | 22% | 32%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
tensorflow_examples/profiling31% | 28% | 19% | 8% | 12%
tensorflow_examples/lite/model_maker0% | 10% | 36% | 28% | 24%
tensorflow_examples/models/densenet0% | 14% | 44% | 18% | 22%
tensorflow_examples/models/nmt_with_attention0% | 0% | 27% | 30% | 41%
tensorflow_examples/models/pix2pix0% | 0% | 25% | 38% | 36%
lite/codelabs/digit_classifier0% | 0% | 44% | 22% | 32%
lite/tools0% | 0% | 60% | 0% | 40%
tensorflow_examples/models/dcgan0% | 0% | 0% | 70% | 29%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def resnet50()
in tensorflow_examples/profiling/resnet_model.py
149 4 4
def __init__()
in tensorflow_examples/models/densenet/densenet.py
79 14 14
def conv_block()
in tensorflow_examples/profiling/resnet_model.py
75 2 7
def __init__()
in tensorflow_examples/lite/model_maker/core/task/model_spec/object_detector_spec.py
75 10 10
def run()
in tensorflow_examples/lite/model_maker/pip_package/setup_util.py
74 14 1
def gen_dataset()
in tensorflow_examples/lite/model_maker/core/data_util/audio_dataloader.py
67 13 7
def _create_metadata()
in tensorflow_examples/lite/model_maker/core/task/metadata_writer_for_image_classifier.py
60 1 1
def identity_block()
in tensorflow_examples/profiling/resnet_model.py
59 2 6
def _create_metadata()
in tensorflow_examples/lite/model_maker/core/task/metadata_writers/text_classifier/metadata_writer_for_text_classifier.py
56 1 1
def create()
in tensorflow_examples/lite/model_maker/core/task/image_classifier.py
51 4 17
def __init__()
in tensorflow_examples/lite/model_maker/core/task/model_spec/text_spec.py
51 4 16
def from_movielens()
in tensorflow_examples/lite/model_maker/core/data_util/recommendation_dataloader.py
43 5 15
def from_folder()
in tensorflow_examples/lite/model_maker/core/data_util/text_dataloader.py
43 12 7
def main()
in tensorflow_examples/models/densenet/distributed_train.py
43 4 20
def create_classifier_model()
in tensorflow_examples/lite/model_maker/core/task/model_spec/text_spec.py
42 3 7
def custom_loop()
in tensorflow_examples/models/densenet/distributed_train.py
41 6 4
def input_fn()
in tensorflow_examples/profiling/imagenet_preprocessing_ineffecient_input_pipeline.py
38 10 12
def create_qa_model()
in tensorflow_examples/lite/model_maker/core/task/model_spec/text_spec.py
38 3 6
def __init__()
in tensorflow_examples/lite/model_maker/core/task/model_spec/text_spec.py
38 2 21
def unet_generator()
in tensorflow_examples/models/pix2pix/pix2pix.py
38 4 2