facebookresearch / CompilerGym
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 796 units with 7,329 lines of code in units (37.2% of code).
    • 4 very long units (834 lines of code)
    • 8 long units (606 lines of code)
    • 74 medium size units (2,179 lines of code)
    • 83 small units (1,177 lines of code)
    • 627 very small units (2,533 lines of code)
11% | 8% | 29% | 16% | 34%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
py8% | 9% | 28% | 16% | 37%
cc25% | 6% | 40% | 8% | 18%
h0% | 0% | 29% | 24% | 45%
js0% | 0% | 0% | 52% | 47%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
compiler_gym/envs18% | 10% | 35% | 11% | 23%
compiler_gym/views51% | 0% | 0% | 7% | 40%
www0% | 56% | 16% | 12% | 13%
compiler_gym/leaderboard0% | 67% | 26% | 0% | 6%
compiler_gym/service0% | 6% | 46% | 15% | 31%
compiler_gym/util0% | 0% | 18% | 28% | 53%
compiler_gym0% | 0% | 30% | 29% | 40%
leaderboard/llvm_instcount0% | 0% | 72% | 18% | 8%
compiler_gym/datasets0% | 0% | 11% | 22% | 66%
www/frontends0% | 0% | 0% | 52% | 47%
compiler_gym/wrappers0% | 0% | 0% | 18% | 81%
compiler_gym/spaces0% | 0% | 0% | 15% | 84%
ROOT0% | 0% | 0% | 0% | 100%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
def make_gcc_compilation_session()
in compiler_gym/envs/gcc/service/gcc_service.py
389 70 1
cc
Status setObservation()
in compiler_gym/envs/llvm/service/Observation.cc
178 33 4
cc
std::vector getLlvmObservationSpaceList()
in compiler_gym/envs/llvm/service/ObservationSpaces.cc
159 28 0
def from_proto()
in compiler_gym/views/observation_space_spec.py
108 14 3
def validator_cb()
in compiler_gym/envs/llvm/datasets/cbench.py
92 21 1
cc
Status getTextSizeInBytes()
in compiler_gym/envs/llvm/service/Cost.cc
90 10 4
def _gcc_parse_optimize()
in compiler_gym/envs/gcc/gcc.py
82 15 1
def validate()
in compiler_gym/envs/compiler_env.py
82 14 2
def _gcc_parse_params()
in compiler_gym/envs/gcc/gcc.py
72 15 1
def _step()
in www/www.py
71 7 1
def eval_llvm_instcount_policy()
in compiler_gym/leaderboard/llvm_instcount.py
66 14 1
def main()
in compiler_gym/service/runtime/create_and_run_compiler_gym_service.py
51 8 1
def proto_to_choice_space()
in compiler_gym/service/proto/py_converters.py
50 9 1
def benchmark_from_parsed_uri()
in compiler_gym/envs/llvm/datasets/poj104.py
50 9 2
cc
Status LlvmSession::handleSessionParameter()
in compiler_gym/envs/llvm/service/LlvmSession.cc
50 15 3
cc
Status LlvmSession::runOptWithArgs()
in compiler_gym/envs/llvm/service/LlvmSession.cc
49 8 1
def get_llvm_datasets()
in compiler_gym/envs/llvm/datasets/__init__.py
48 3 1
def benchmark_from_parsed_uri()
in compiler_gym/envs/llvm/datasets/clgen.py
48 6 2
def replay_actions()
in compiler_gym/random_search.py
44 4 3
def e_greedy_search()
in leaderboard/llvm_instcount/e_greedy/e_greedy.py
42 12 1