Esempio n. 1
0
func (a *accounter) Finish() string {
	var message string
	a.finishOnce.Do(func() {
		close(a.isFinished)
		message = fmt.Sprintf("Total: %s, Transferred: %s, Speed: %s", pb.FormatBytes(a.Total),
			pb.FormatBytes(a.current), a.write(atomic.LoadInt64(&a.current)))
	})
	return message
}
Esempio n. 2
0
// copyStatMessage copy accounting message
func (c copyStatMessage) String() string {
	speedBox := pb.FormatBytes(int64(c.Speed))
	if speedBox == "" {
		speedBox = "0 MB"
	} else {
		speedBox = speedBox + "/s"
	}
	message := fmt.Sprintf("Total: %s, Transferred: %s, Speed: %s", pb.FormatBytes(c.Total),
		pb.FormatBytes(c.Transferred), speedBox)
	return message
}
Esempio n. 3
0
File: main.go Progetto: dudymas/mc
// Get os/arch/platform specific information.
// Returns a map of current os/arch/platform/memstats
func getSystemData() map[string]string {
	host, e := os.Hostname()
	fatalIf(probe.NewError(e), "Unable to determine the hostname.")

	memstats := &runtime.MemStats{}
	runtime.ReadMemStats(memstats)
	mem := fmt.Sprintf("Used: %s | Allocated: %s | UsedHeap: %s | AllocatedHeap: %s",
		pb.FormatBytes(int64(memstats.Alloc)),
		pb.FormatBytes(int64(memstats.TotalAlloc)),
		pb.FormatBytes(int64(memstats.HeapAlloc)),
		pb.FormatBytes(int64(memstats.HeapSys)))
	platform := fmt.Sprintf("Host: %s | OS: %s | Arch: %s", host, runtime.GOOS, runtime.GOARCH)
	goruntime := fmt.Sprintf("Version: %s | CPUs: %s", runtime.Version(), strconv.Itoa(runtime.NumCPU()))
	return map[string]string{
		"PLATFORM": platform,
		"RUNTIME":  goruntime,
		"MEM":      mem,
	}
}
Esempio n. 4
0
// Get os/arch/platform specific information.
// Returns a map of current os/arch/platform/memstats
func getSystemData() map[string]string {
	host, err := os.Hostname()
	if err != nil {
		console.Fatalf("Unable to determine hostname. %s\n", err)
	}
	memstats := &runtime.MemStats{}
	runtime.ReadMemStats(memstats)
	mem := fmt.Sprintf("Used: %s | Allocated: %s | UsedHeap: %s | AllocatedHeap: %s",
		pb.FormatBytes(int64(memstats.Alloc)),
		pb.FormatBytes(int64(memstats.TotalAlloc)),
		pb.FormatBytes(int64(memstats.HeapAlloc)),
		pb.FormatBytes(int64(memstats.HeapSys)))
	platform := fmt.Sprintf("Host: %s | OS: %s | Arch: %s", host, runtime.GOOS, runtime.GOARCH)
	goruntime := fmt.Sprintf("Version: %s | CPUs: %s", runtime.Version(), strconv.Itoa(runtime.NumCPU()))
	return map[string]string{
		"PLATFORM": platform,
		"RUNTIME":  goruntime,
		"MEM":      mem,
		"TAG":      Tag,
	}
}
Esempio n. 5
0
func (a *accounter) write(current int64) string {
	var speedBox string
	fromStart := time.Now().Sub(a.startTime)
	currentFromStart := current - a.startValue

	if currentFromStart > 0 {
		speed := float64(currentFromStart) / (float64(fromStart) / float64(time.Second))
		speedBox = pb.FormatBytes(int64(speed))
	}
	if speedBox == "" {
		speedBox = "0 MB"
	}
	return speedBox + "/s"
}