func main() { // validateFlags() will exit on error memSize, weights, sizes := flags.ValidateFlags() switchFuns := switches.AllJreSwitchFuns allocator, err := memory.NewAllocator(sizes, weights) if err != nil { fmt.Fprintf(os.Stderr, "Cannot allocate memory: %s", err) os.Exit(1) } if err = allocator.Balance(memSize); err != nil { fmt.Fprintf(os.Stderr, "Cannot balance memory: %s", err) os.Exit(1) } if warnings := allocator.GetWarnings(); len(warnings) != 0 { fmt.Fprintln(os.Stderr, strings.Join(warnings, "\n")) } switches := allocator.Switches(switchFuns) fmt.Fprint(os.Stdout, strings.Join(switches, " ")) }
func main() { // validateFlags() will exit on error memSize, numThreads, weights, sizes, initials := flags.ValidateFlags() allocator, err := memory.NewAllocator(sizes, weights) if err != nil { fmt.Fprintf(os.Stderr, "Cannot allocate memory: %s", err) os.Exit(1) } if err = allocator.Balance(memSize, numThreads); err != nil { fmt.Fprintf(os.Stderr, "Cannot balance memory: %s", err) os.Exit(1) } allocator.GenerateInitialAllocations(initials) allocatorSwitches := allocator.Switches(switches.AllocatorJreSwitchFuns) if warnings := allocator.GetWarnings(); len(warnings) != 0 { fmt.Fprintln(os.Stderr, strings.Join(warnings, "\n")) } fmt.Fprint(os.Stdout, strings.Join(allocatorSwitches, " ")) }
sizes = strmap{ "stack": "2m", "heap": "30m..", "permgen": "10m", } weights = floatmap{ "stack": 1.0, "heap": 5.0, "permgen": 3.0, "native": 1.0, } }) JustBeforeEach(func() { a = shouldWork(memory.NewAllocator(convertToRanges(sizes), weights)) }) It("succeeds", func() { Ω(memory.GetBuckets(a)).Should(ConsistOf( "Bucket{name: stack, size: <nil>, range: 2M..2M, weight: 1}", "Bucket{name: heap, size: <nil>, range: 30M.., weight: 5}", "Bucket{name: permgen, size: <nil>, range: 10M..10M, weight: 3}", "Bucket{name: native, size: <nil>, range: 0.., weight: 1}", )) }) }) }) Context("balancing", func() { var (