pytorch / opacus
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 241 units with 1,816 lines of code in units (33.2% of code).
    • 0 very long units (0 lines of code)
    • 3 long units (197 lines of code)
    • 9 medium size units (259 lines of code)
    • 35 small units (476 lines of code)
    • 194 very small units (884 lines of code)
0% | 10% | 14% | 26% | 48%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
js0% | 72% | 10% | 13% | 4%
py0% | 0% | 14% | 28% | 56%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
website/pages0% | 100% | 0% | 0% | 0%
website/core0% | 41% | 21% | 28% | 8%
opacus/layers0% | 0% | 25% | 15% | 58%
website/scripts0% | 0% | 100% | 0% | 0%
opacus0% | 0% | 20% | 22% | 57%
opacus/scripts0% | 0% | 75% | 0% | 25%
opacus/accountants0% | 0% | 13% | 34% | 51%
opacus/optimizers0% | 0% | 0% | 35% | 64%
opacus/validators0% | 0% | 0% | 53% | 46%
opacus/utils0% | 0% | 0% | 37% | 62%
ROOT0% | 0% | 0% | 70% | 29%
opacus/grad_sample0% | 0% | 0% | 11% | 88%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
render()
in website/pages/tutorials/index.js
79 1 0
render()
in website/pages/en/index.js
63 3 0
render()
in website/core/TutorialSidebar.js
55 2 0
def main()
in opacus/scripts/compute_dp_sgd_privacy.py
48 2 0
def load_state_dict()
in opacus/layers/dp_multihead_attention.py
30 8 2
def gen_tutorials()
in website/scripts/parse_tutorials.py
29 5 1
def switch_generator()
in opacus/data_loader.py
28 5 3
render()
in website/core/Tutorial.js
28 1 0
def initialize_cells()
in opacus/layers/dp_rnn.py
27 8 1
def _compute_log_a_for_frac_alpha()
in opacus/accountants/analysis/rdp.py
25 5 3
def parse_sphinx()
in website/scripts/parse_sphinx.py
23 5 2
def __init__()
in opacus/privacy_engine.py
21 3 4
function SocialFooter()
in website/core/Footer.js
19 1 1
def accumulated_iterations()
in opacus/optimizers/optimizer.py
18 6 1
def fix()
in opacus/validators/module_validator.py
18 6 2
function renderDownloadIcon()
in website/core/Tutorial.js
18 1 0
def __iter__()
in opacus/utils/uniform_sampler.py
17 5 1
def clip_and_accumulate()
in opacus/optimizers/optimizer.py
17 4 1
def __init__()
in opacus/data_loader.py
16 1 0
def remove_hooks()
in opacus/grad_sample/grad_sample_module.py
16 6 1