microsoft / snmalloc
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 372 units with 4,002 lines of code in units (45.6% of code).
    • 1 very long units (159 lines of code)
    • 7 long units (483 lines of code)
    • 34 medium size units (1,053 lines of code)
    • 68 small units (943 lines of code)
    • 262 very small units (1,364 lines of code)
3% | 12% | 26% | 23% | 34%
Legend:
101+
51-100
21-50
11-20
1-10
Unit Size per Extension
101+
51-100
21-50
11-20
1-10
h4% | 12% | 26% | 22% | 33%
cc0% | 0% | 0% | 47% | 53%
Unit Size per Logical Component
primary logical decomposition
101+
51-100
21-50
11-20
1-10
src/ds21% | 0% | 15% | 26% | 35%
src/mem0% | 19% | 33% | 16% | 30%
src/backend0% | 16% | 17% | 31% | 35%
src/pal0% | 0% | 28% | 42% | 29%
src/aal0% | 0% | 14% | 8% | 77%
src/override0% | 0% | 0% | 47% | 53%
Alternative Visuals
Longest Units
Top 20 longest units
Unit# linesMcCabe index# params
void on_clear()
in src/ds/dllist.h
159 13 1
class alignas()
in src/mem/metaslab.h
95 2 1
struct alignas()
in src/mem/remoteallocator.h
82 4 1
void print()
in src/mem/allocstats.h
69 6 3
64 4 5
static capptr::Chunk reserve()
in src/backend/backend.h
60 11 3
57 7 1
bool post()
in src/mem/remotecache.h
56 8 3
SNMALLOC_FAST_PATH void dealloc()
in src/mem/localalloc.h
49 9 1
constexpr SizeClassTable()
in src/mem/sizeclasstable.h
49 6 0
static uint64_t get_entropy64()
in src/pal/pal_linux.h
47 8 0
46 5 1
static uint64_t dev_urandom()
in src/pal/pal_posix.h
41 7 0
std::enable_if_t init()
in src/backend/pagemap.h
38 3 0
38 3 2
bool flush()
in src/mem/corealloc.h
38 5 1
SNMALLOC_SLOW_PATH decltype()
in src/mem/corealloc.h
37 3 1
static void register_local_state()
in src/mem/chunkallocator.h
35 5 2
34 4 1
34 4 1