pytorch / tutorials
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 940 units with 7,789 lines of code in units (50.5% of code).
    • 4 very long units (505 lines of code)
    • 5 long units (301 lines of code)
    • 45 medium size units (1,427 lines of code)
    • 139 small units (1,987 lines of code)
    • 747 very small units (3,569 lines of code)
6% | 3% | 18% | 25% | 45%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
js17% | 11% | 14% | 18% | 37%
py2% | 1% | 19% | 27% | 49%
cpp0% | 0% | 17% | 49% | 33%
h0% | 0% | 0% | 0% | 100%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
_static17% | 11% | 16% | 17% | 37%
advanced_source33% | 0% | 17% | 6% | 42%
beginner_source0% | 3% | 15% | 37% | 43%
intermediate_source0% | 0% | 22% | 32% | 45%
ROOT0% | 0% | 85% | 14% | 0%
advanced_source/rpc_ddp_tutorial0% | 0% | 90% | 0% | 9%
advanced_source/transformer__timeseries_cpp_tutorial0% | 0% | 24% | 42% | 33%
beginner_source/nlp0% | 0% | 18% | 22% | 58%
beginner_source/basics0% | 0% | 0% | 40% | 59%
prototype_source0% | 0% | 0% | 25% | 74%
beginner_source/introyt0% | 0% | 0% | 9% | 90%
advanced_source/dispatcher0% | 0% | 0% | 32% | 67%
recipes_source/recipes0% | 0% | 0% | 6% | 93%
advanced_source/torch_script_custom_ops0% | 0% | 0% | 73% | 26%
advanced_source/torch_script_custom_classes0% | 0% | 0% | 33% | 66%
beginner_source/former_torchies0% | 0% | 0% | 14% | 85%
beginner_source/blitz0% | 0% | 0% | 0% | 100%
beginner_source/hybrid_frontend0% | 0% | 0% | 0% | 100%
beginner_source/examples_nn0% | 0% | 0% | 0% | 100%
beginner_source/examples_autograd0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def run_worker()
in advanced_source/ddp_pipeline.py
150 20 2
(function($)()
in _static/websupport.js
142 4 1
this.stemWord = function()
in _static/searchtools.js
111 29 1
(function()()
in _static/underscore-1.3.1.js
102 20 1
def train_cifar()
in beginner_source/hyperparameter_tuning_tutorial.py
66 8 3
query : function()
in _static/searchtools.js
64 16 1
performTermsSearch : function()
in _static/searchtools.js
60 19 4
function eq()
in _static/underscore-1.3.1.js
58 41 3
performObjectSearch : function()
in _static/searchtools.js
53 15 2
def run_worker()
in advanced_source/rpc_ddp_tutorial/main.py
46 12 2
def train()
in beginner_source/chatbot_tutorial.py
44 6 13
def train_model()
in beginner_source/transfer_learning_tutorial.py
43 12 5
def main()
in beginner_source/hyperparameter_tuning_tutorial.py
43 3 3
var Stemmer = function()
in _static/searchtools.js
42 1 0
$.fn.comment = function()
in _static/websupport.js
42 4 0
function highlight()
in _static/doctools.js
41 8 2
def forward()
in intermediate_source/named_tensor_tutorial.py
40 7 5
def get_style_model_and_losses()
in advanced_source/neural_style_tutorial.py
38 11 7
def run_style_transfer()
in advanced_source/neural_style_tutorial.py
38 6 9
def run()
in custom_directives.py
38 8 1