forked from layou233/NeverIdle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
67 lines (56 loc) · 1.52 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"flag"
"fmt"
"math/rand"
"runtime"
"time"
"github.com/layou233/neveridle/waste"
)
const Version = "0.1"
var (
FlagCPU = flag.Duration("c", 0, "Interval for CPU waste")
FlagMemory = flag.Int("m", 0, "GiB of memory waste")
FlagNetwork = flag.Duration("n", 0, "Interval for network speed test")
)
func main() {
rand.Seed(time.Now().UnixNano())
fmt.Println("NeverIdle", Version, "- Getting worse from here.")
fmt.Println("Platform:", runtime.GOOS, ",", runtime.GOARCH, ",", runtime.Version())
fmt.Println("GitHub: https://github.com/layou233/NeverIdle")
flag.Parse()
nothingEnabled := true
if *FlagMemory != 0 {
nothingEnabled = false
fmt.Println("====================")
fmt.Println("Starting memory wasting of", *FlagMemory, "GiB")
go waste.Memory(*FlagMemory)
runtime.Gosched()
fmt.Println("====================")
}
if *FlagCPU != 0 {
nothingEnabled = false
fmt.Println("====================")
fmt.Println("Starting CPU wasting with interval", *FlagCPU)
go waste.CPU(*FlagCPU)
runtime.Gosched()
fmt.Println("====================")
}
if *FlagNetwork != 0 {
nothingEnabled = false
fmt.Println("====================")
fmt.Println("Starting network speed testing with interval", *FlagNetwork)
go waste.Network(*FlagNetwork)
runtime.Gosched()
fmt.Println("====================")
}
if nothingEnabled {
flag.PrintDefaults()
} else {
// fatal error: all goroutines are asleep - deadlock!
// select {} // fall asleep
for {
time.Sleep(24 * time.Hour)
}
}
}