init
This commit is contained in:
39
cmd/estimate/main.go
Normal file
39
cmd/estimate/main.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"git.intruders.space/bot/mapsize"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
panic("need argument")
|
||||
}
|
||||
|
||||
n, err := strconv.Atoi(os.Args[1])
|
||||
if err != nil {
|
||||
panic("bad argument")
|
||||
}
|
||||
|
||||
m := make(map[string]string)
|
||||
ms := mapsize.New()
|
||||
|
||||
for i := 0; i < n*1_000_000; i++ {
|
||||
k := strconv.FormatUint(rand.Uint64(), 10)
|
||||
v := "abc"
|
||||
|
||||
m[k] = v
|
||||
ms.Add(len(k), len(v))
|
||||
}
|
||||
|
||||
fmt.Println("do you want an estimate? (y/y)")
|
||||
var c byte
|
||||
fmt.Scan(&c)
|
||||
|
||||
fmt.Printf("\nestimate: %d kB\n", ms.Size()/1024)
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user