mapsize

package module
v0.0.0-...-0304675 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 2 Imported by: 0

README

MapSize

How much memory is occupied by map.

go get github.com/520MianXiangDuiXiang520/MapSize
package main

import (
	"fmt"
	"github.com/520MianXiangDuiXiang520/MapSize"
)

func main() {
	m := make(map[int]struct{})
	for i := 0; i < 100; i++ {
		m[i] = struct{}{}
	}
	fmt.Println(mapsize.Size(m)) // 1416
}

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Size

func Size[K comparable, V any](m map[K]V) int64

Size returns how many bytes of memory a map occupies, which is an approximation, but has reference value

Example
m := make(map[int]struct{})
for i := 0; i < 100; i++ {
	m[i] = struct{}{}
}
fmt.Println(Size(m)) // 1416
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL