2017-03-07 12:44:16 +00:00
|
|
|
// Copyright (C) 2014 The Syncthing Authors.
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
// You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2021-08-17 08:10:41 +00:00
|
|
|
//go:build integration && benchmark && !windows
|
2017-03-07 12:44:16 +00:00
|
|
|
// +build integration,benchmark,!windows
|
|
|
|
|
|
|
|
package integration
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"syscall"
|
|
|
|
"time"
|
2022-07-28 17:36:39 +00:00
|
|
|
|
|
|
|
"github.com/syncthing/syncthing/lib/build"
|
2017-03-07 12:44:16 +00:00
|
|
|
)
|
|
|
|
|
2019-05-18 06:46:08 +00:00
|
|
|
func printUsage(name string, proc *os.ProcessState, total int64) {
|
2017-03-07 12:44:16 +00:00
|
|
|
if rusage, ok := proc.SysUsage().(*syscall.Rusage); ok {
|
2019-05-18 06:46:08 +00:00
|
|
|
mib := total / 1024 / 1024
|
|
|
|
log.Printf("%s: Utime: %s / MiB", name, time.Duration(rusage.Utime.Nano()/mib))
|
|
|
|
log.Printf("%s: Stime: %s / MiB", name, time.Duration(rusage.Stime.Nano()/mib))
|
2022-07-28 17:36:39 +00:00
|
|
|
if build.IsDarwin {
|
2017-03-07 12:44:16 +00:00
|
|
|
// Darwin reports in bytes, Linux seems to report in KiB even
|
|
|
|
// though the manpage says otherwise.
|
|
|
|
rusage.Maxrss /= 1024
|
|
|
|
}
|
|
|
|
log.Printf("%s: MaxRSS: %d KiB", name, rusage.Maxrss)
|
|
|
|
}
|
|
|
|
}
|