/
versioned.go
114 lines (104 loc) · 3.02 KB
/
versioned.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* Warp (C) 2019-2020 MinIO, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cli
import (
"net/http"
"github.com/minio/cli"
"github.com/minio/mc/pkg/probe"
"github.com/minio/minio-go/v7"
"github.com/minio/pkg/v2/console"
"github.com/minio/warp/pkg/bench"
)
var versionedFlags = []cli.Flag{
cli.IntFlag{
Name: "objects",
Value: 250,
Usage: "Number of objects to upload.",
},
cli.StringFlag{
Name: "obj.size",
Value: "10MiB",
Usage: "Size of each generated object. Can be a number or 10KiB/MiB/GiB. All sizes are base 2 binary.",
},
cli.Float64Flag{
Name: "get-distrib",
Usage: "The amount of GET operations.",
Value: 45,
},
cli.Float64Flag{
Name: "stat-distrib",
Usage: "The amount of STAT operations.",
Value: 30,
},
cli.Float64Flag{
Name: "put-distrib",
Usage: "The amount of PUT operations.",
Value: 15,
},
cli.Float64Flag{
Name: "delete-distrib",
Usage: "The amount of DELETE operations. Must be at least the same as PUT.",
Value: 10,
},
}
var versionedCmd = cli.Command{
Name: "versioned",
Usage: "benchmark mixed versioned objects",
Action: mainVersioned,
Before: setGlobalsFromContext,
Flags: combineFlags(globalFlags, ioFlags, versionedFlags, genFlags, benchFlags, analyzeFlags),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
USAGE:
{{.HelpName}} [FLAGS]
-> see https://github.com/minio/warp#mixed
FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}`,
}
// mainVersioned is the entry point for mixed command.
func mainVersioned(ctx *cli.Context) error {
checkVersionedSyntax(ctx)
sse := newSSE(ctx)
dist := bench.VersionedDistribution{
Distribution: map[string]float64{
http.MethodGet: ctx.Float64("get-distrib"),
"STAT": ctx.Float64("stat-distrib"),
http.MethodPut: ctx.Float64("put-distrib"),
http.MethodDelete: ctx.Float64("delete-distrib"),
},
}
err := dist.Generate(ctx.Int("objects") * 2)
fatalIf(probe.NewError(err), "Invalid distribution")
b := bench.Versioned{
Common: getCommon(ctx, newGenSource(ctx, "obj.size")),
CreateObjects: ctx.Int("objects"),
GetOpts: minio.GetObjectOptions{ServerSideEncryption: sse},
StatOpts: minio.StatObjectOptions{
ServerSideEncryption: sse,
},
Dist: &dist,
}
return runBench(ctx, &b)
}
func checkVersionedSyntax(ctx *cli.Context) {
if ctx.NArg() > 0 {
console.Fatal("Command takes no arguments")
}
checkAnalyze(ctx)
checkBenchmark(ctx)
}