tensorflow / lingvo
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 5,983 units with 88,898 lines of code in units (86.7% of code).
    • 56 very long units (7,664 lines of code)
    • 257 long units (16,901 lines of code)
    • 974 medium size units (30,481 lines of code)
    • 1,164 small units (17,022 lines of code)
    • 3,532 very small units (16,830 lines of code)
8% | 19% | 34% | 19% | 18%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py7% | 19% | 34% | 19% | 19%
cc26% | 14% | 35% | 12% | 10%
h0% | 31% | 32% | 8% | 28%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
lingvo/core7% | 17% | 34% | 20% | 20%
lingvo/core/ops24% | 14% | 37% | 11% | 12%
lingvo/tasks/car5% | 22% | 32% | 19% | 19%
lingvo/jax10% | 15% | 29% | 23% | 22%
lingvo17% | 24% | 29% | 12% | 15%
lingvo/tasks/mt9% | 36% | 38% | 6% | 8%
lingvo/jax/layers8% | 23% | 36% | 20% | 11%
lingvo/tasks/asr10% | 22% | 32% | 14% | 19%
lingvo/tasks/lm0% | 18% | 45% | 18% | 17%
lingvo/tasks/punctuator0% | 30% | 28% | 26% | 14%
lingvo/tools0% | 9% | 32% | 28% | 29%
lingvo/tasks/milan0% | 0% | 30% | 41% | 28%
lingvo/jax/tasks0% | 0% | 51% | 35% | 13%
lingvo/tasks/image0% | 0% | 47% | 16% | 35%
lingvo/core/steps0% | 0% | 39% | 22% | 37%
docker0% | 0% | 43% | 0% | 57%
pip_package0% | 0% | 0% | 0% | 100%
lingvo/jax/pip_package0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def FPropFn()
in lingvo/core/gshard_layers.py
277 50 7
def flat_beam_search()
in lingvo/core/flat_beam_search_helper.py
241 42 16
214 32 8
def Params()
in lingvo/core/base_model.py
204 2 1
Status ComputeTopK()
in lingvo/core/ops/beam_search_step_op_kernels.cc
203 41 22
def Top2GatingOnLogits()
in lingvo/core/gshard_layers.py
192 34 14
def __init__()
in lingvo/core/recurrent.py
183 38 13
def Export()
in lingvo/core/inference_graph_exporter.py
183 58 9
def __init__()
in lingvo/executor.py
178 29 5
def train_and_evaluate_pmap()
in lingvo/jax/train.py
173 22 7
def CreateTpuEnqueueOps()
in lingvo/core/base_input_generator.py
168 25 4
void SanityCheckInputs()
in lingvo/core/ops/beam_search_step_op_kernels.cc
161 3 1
PSUtils::Result PSUtils::DoSampling()
in lingvo/tasks/car/ops/ps_utils.cc
152 31 3
def TransformFeatures()
in lingvo/tasks/car/input_preprocessors.py
149 18 2
def __init__()
in lingvo/core/attention.py
147 7 2
def FProp()
in lingvo/core/gpipe.py
144 27 3
def _BodyFPropInternal()
in lingvo/core/gshard_layers.py
141 27 8
def recurrent_func()
in lingvo/jax/layers/recurrent.py
140 2 7
def top2_gating_on_logits()
in lingvo/jax/gshard_utils.py
139 19 12
def _StackedRecurrent()
in lingvo/core/recurrent.py
135 19 10