MCPcopy Create free account
hub / github.com/cloudfoundry/java-buildpack-memory-calculator / main

Function main

main.go:29–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27)
28
29func main() {
30 h := flags.DefaultHeadRoom
31 j := flags.DefaultJVMOptions
32 l := flags.DefaultLoadedClassCount
33 t := flags.DefaultThreadCount
34 m := flags.DefaultTotalMemory
35
36 c := calculator.Calculator{HeadRoom: &h, JvmOptions: &j, LoadedClassCount: &l, ThreadCount: &t, TotalMemory: &m}
37
38 flag.Var(c.HeadRoom, flags.FlagHeadRoom, "percentage of total memory available which will be left unallocated to cover JVM overhead")
39 flag.Var(c.JvmOptions, flags.FlagJVMOptions, "JVM options, typically JAVA_OPTS")
40 flag.Var(c.LoadedClassCount, flags.FlagLoadedClassCount, "the number of classes that will be loaded when the application is running")
41 flag.Var(c.ThreadCount, flags.FlagThreadCount, "the number of user threads")
42 flag.Var(c.TotalMemory, "total-memory", "total memory available to the application, typically expressed with size classification (B, K, M, G, T)")
43 flag.Parse()
44
45 if !validate(c.HeadRoom, c.JvmOptions, c.LoadedClassCount, c.ThreadCount, c.TotalMemory) {
46 _, _ = fmt.Fprintln(os.Stderr, "")
47 flag.Usage()
48 os.Exit(1)
49 }
50
51 o, err := c.Calculate()
52 if err != nil {
53 _, _ = fmt.Fprintf(os.Stderr, err.Error())
54 os.Exit(2)
55 }
56
57 s := make([]string, len(o))
58 for i, t := range o {
59 s[i] = t.String()
60 }
61
62 fmt.Println(output(o))
63}
64
65func output(o []fmt.Stringer) string {
66 s := make([]string, len(o))

Callers

nothing calls this directly

Calls 4

CalculateMethod · 0.95
validateFunction · 0.85
outputFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected