diff --git a/benchmarks/gluon_bench/flags/imap_benchmarks.go b/benchmarks/gluon_bench/flags/imap_benchmarks.go index 5ce0ac92..07921841 100644 --- a/benchmarks/gluon_bench/flags/imap_benchmarks.go +++ b/benchmarks/gluon_bench/flags/imap_benchmarks.go @@ -3,9 +3,9 @@ package flags import "flag" var ( - RemoteServer = flag.String("remote-server", "", "IP address and port of the remote IMAP server to run against. E.g. 127.0.0.1:1143.") - MessageCount = flag.Uint("msg-count", 1000, "Number of messages to add to the mailbox before each benchmark") - RandomSeqSetIntervals = flag.Bool("random-seqset-intervals", false, "When set, generate random sequence intervals rather than single numbers.") - UIDMode = flag.Bool("uid-mode", false, "When set, will run benchmarks in UID mode if available.") - ParallelClients = flag.Uint("parallel-clients", 1, "Set the number of clients to be run in parallel during the benchmark.") + IMAPRemoteServer = flag.String("imap-remote-server", "", "IP address and port of the remote IMAP server to run against. E.g. 127.0.0.1:1143.") + IMAPMessageCount = flag.Uint("imap-msg-count", 1000, "Number of messages to add to the mailbox before each benchmark") + IMAPRandomSeqSetIntervals = flag.Bool("imap-random-seqset-intervals", false, "When set, generate random sequence intervals rather than single numbers.") + IMAPUIDMode = flag.Bool("imap-uid-mode", false, "When set, will run benchmarks in UID mode if available.") + IMAPParallelClients = flag.Uint("imap-parallel-clients", 1, "Set the number of clients to be run in parallel during the benchmark.") ) diff --git a/benchmarks/gluon_bench/gluon_benchmarks/sync.go b/benchmarks/gluon_bench/gluon_benchmarks/sync.go index 83667d77..7ef25858 100644 --- a/benchmarks/gluon_bench/gluon_benchmarks/sync.go +++ b/benchmarks/gluon_bench/gluon_benchmarks/sync.go @@ -33,7 +33,7 @@ func NewSync() benchmark.Benchmark { } func (s *Sync) Name() string { - return "sync" + return "gluon-sync" } func (s *Sync) Setup(ctx context.Context, benchmarkDir string) error { diff --git a/benchmarks/gluon_bench/imap_benchmarks/append.go b/benchmarks/gluon_bench/imap_benchmarks/append.go index 1cca7f32..d74037ac 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/append.go +++ b/benchmarks/gluon_bench/imap_benchmarks/append.go @@ -19,16 +19,16 @@ func NewAppend() benchmark.Benchmark { } func (a *Append) Name() string { - return "append" + return "imap-append" } func (a *Append) Setup(ctx context.Context, addr net.Addr) error { - if *flags.MessageCount == 0 { + if *flags.IMAPMessageCount == 0 { return fmt.Errorf("invalid message count") } return WithClient(addr, func(cl *client.Client) error { - for i := uint(0); i < *flags.ParallelClients; i++ { + for i := uint(0); i < *flags.IMAPParallelClients; i++ { if _, err := a.createRandomMBox(cl); err != nil { return err } @@ -44,7 +44,7 @@ func (a *Append) TearDown(ctx context.Context, addr net.Addr) error { func (a *Append) Run(ctx context.Context, addr net.Addr) error { RunParallelClients(addr, func(c *client.Client, u uint) { - if err := BuildMailbox(c, a.MBoxes[u], int(*flags.MessageCount)); err != nil { + if err := BuildMailbox(c, a.MBoxes[u], int(*flags.IMAPMessageCount)); err != nil { panic(err) } }) diff --git a/benchmarks/gluon_bench/imap_benchmarks/client.go b/benchmarks/gluon_bench/imap_benchmarks/client.go index 667063f5..4570dc14 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/client.go +++ b/benchmarks/gluon_bench/imap_benchmarks/client.go @@ -159,8 +159,8 @@ type MailboxInfo struct { } func RunParallelClientsWithMailbox(addr net.Addr, mbox string, readOnly bool, fn func(*client.Client, uint)) { - mailboxes := make([]MailboxInfo, *flags.ParallelClients) - for i := uint(0); i < *flags.ParallelClients; i++ { + mailboxes := make([]MailboxInfo, *flags.IMAPParallelClients) + for i := uint(0); i < *flags.IMAPParallelClients; i++ { mailboxes[i] = MailboxInfo{Name: mbox, ReadOnly: readOnly} } @@ -168,7 +168,7 @@ func RunParallelClientsWithMailbox(addr net.Addr, mbox string, readOnly bool, fn } func RunParallelClientsWithMailboxes(addr net.Addr, mailboxes []MailboxInfo, fn func(*client.Client, uint)) { - if len(mailboxes) != int(*flags.ParallelClients) { + if len(mailboxes) != int(*flags.IMAPParallelClients) { panic("Mailbox count doesn't match worker count") } @@ -186,7 +186,7 @@ func RunParallelClientsWithMailboxes(addr net.Addr, mailboxes []MailboxInfo, fn func RunParallelClients(addr net.Addr, fn func(*client.Client, uint)) { wg := sync.WaitGroup{} - for i := uint(0); i < *flags.ParallelClients; i++ { + for i := uint(0); i < *flags.IMAPParallelClients; i++ { wg.Add(1) go func(index uint) { @@ -206,11 +206,11 @@ func RunParallelClients(addr net.Addr, fn func(*client.Client, uint)) { } func FillMailbox(cl *client.Client, mbox string) error { - if *flags.MessageCount == 0 { + if *flags.IMAPMessageCount == 0 { return fmt.Errorf("message count can't be 0") } - return BuildMailbox(cl, mbox, int(*flags.MessageCount)) + return BuildMailbox(cl, mbox, int(*flags.IMAPMessageCount)) } func WithClient(addr net.Addr, fn func(*client.Client) error) error { diff --git a/benchmarks/gluon_bench/imap_benchmarks/copy.go b/benchmarks/gluon_bench/imap_benchmarks/copy.go index bd8665fe..0a5b254e 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/copy.go +++ b/benchmarks/gluon_bench/imap_benchmarks/copy.go @@ -12,9 +12,9 @@ import ( ) var ( - copyCountFlag = flag.Uint("copy-count", 0, "Total number of messages to copy during copy benchmarks.") - copyListFlag = flag.String("copy-list", "", "Use a list of predefined sequences to copy rather than random generated.") - copyAllFlag = flag.Bool("copy-all", false, "If set, perform a copy of the all messages.") + copyCountFlag = flag.Uint("imap-copy-count", 0, "Total number of messages to copy during copy benchmarks.") + copyListFlag = flag.String("imap-copy-list", "", "Use a list of predefined sequences to copy rather than random generated.") + copyAllFlag = flag.Bool("imap-copy-all", false, "If set, perform a copy of the all messages.") ) type Copy struct { @@ -29,7 +29,7 @@ func NewCopy() benchmark.Benchmark { } func (*Copy) Name() string { - return "copy" + return "imap-copy" } func (c *Copy) Setup(ctx context.Context, addr net.Addr) error { @@ -44,16 +44,16 @@ func (c *Copy) Setup(ctx context.Context, addr net.Addr) error { copyCount := uint32(*copyCountFlag) if copyCount == 0 { - copyCount = uint32(*flags.MessageCount / 2) + copyCount = uint32(*flags.IMAPMessageCount / 2) } seqSets, err := NewParallelSeqSet(copyCount, - *flags.ParallelClients, + *flags.IMAPParallelClients, *copyListFlag, *copyAllFlag, - *flags.RandomSeqSetIntervals, + *flags.IMAPRandomSeqSetIntervals, false, - *flags.UIDMode) + *flags.IMAPUIDMode) if err != nil { return err @@ -75,7 +75,7 @@ func (c *Copy) Run(ctx context.Context, addr net.Addr) error { RunParallelClientsWithMailbox(addr, srcMBox, true, func(cl *client.Client, index uint) { var copyFn func(*client.Client, *imap.SeqSet, string) error - if *flags.UIDMode { + if *flags.IMAPUIDMode { copyFn = func(cl *client.Client, set *imap.SeqSet, mailbox string) error { return cl.UidCopy(set, mailbox) } diff --git a/benchmarks/gluon_bench/imap_benchmarks/expunge.go b/benchmarks/gluon_bench/imap_benchmarks/expunge.go index c4444f2f..4c92b404 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/expunge.go +++ b/benchmarks/gluon_bench/imap_benchmarks/expunge.go @@ -14,10 +14,10 @@ import ( ) var ( - expungeCountFlag = flag.Uint("expunge-count", 0, "Total number of messages to expunge during expunge benchmarks.") - expungeSameMBoxFlag = flag.Bool("expunge-same-mbox", false, "When true run all the expunge test on the same inbox rather than separate ones in parallel.") - expungeListFlag = flag.String("expunge-list", "", "Use a list of predefined sequences to expunge rather than random generated. Only works when -expunge-same-mbox is not set.") - expungeAllFlag = flag.Bool("expunge-all", false, "If set, perform a expunge of the all messages. Only works when -expunge-same-mbox is not set.") + expungeCountFlag = flag.Uint("imap-expunge-count", 0, "Total number of messages to expunge during expunge benchmarks.") + expungeSameMBoxFlag = flag.Bool("imap-expunge-same-mbox", false, "When true run all the expunge test on the same inbox rather than separate ones in parallel.") + expungeListFlag = flag.String("imap-expunge-list", "", "Use a list of predefined sequences to expunge rather than random generated. Only works when -expunge-same-mbox is not set.") + expungeAllFlag = flag.Bool("imap-expunge-all", false, "If set, perform a expunge of the all messages. Only works when -expunge-same-mbox is not set.") ) type Expunge struct { @@ -31,7 +31,7 @@ func NewExpunge() benchmark.Benchmark { } func (*Expunge) Name() string { - return "expunge" + return "imap-expunge" } func (e *Expunge) Setup(ctx context.Context, addr net.Addr) error { @@ -43,33 +43,33 @@ func (e *Expunge) Setup(ctx context.Context, addr net.Addr) error { expungeCount := uint32(*expungeCountFlag) if expungeCount == 0 { - expungeCount = uint32(*flags.MessageCount) / 2 + expungeCount = uint32(*flags.IMAPMessageCount) / 2 } e.seqSets = NewParallelSeqSetExpunge(expungeCount, - *flags.ParallelClients, - *flags.RandomSeqSetIntervals, - *flags.UIDMode, + *flags.IMAPParallelClients, + *flags.IMAPRandomSeqSetIntervals, + *flags.IMAPUIDMode, ) - e.mboxInfo = make([]MailboxInfo, *flags.ParallelClients) + e.mboxInfo = make([]MailboxInfo, *flags.IMAPParallelClients) for i := 0; i < len(e.mboxInfo); i++ { e.mboxInfo[i] = MailboxInfo{Name: e.MBoxes[0], ReadOnly: false} } } else { - for i := uint(0); i < *flags.ParallelClients; i++ { + for i := uint(0); i < *flags.IMAPParallelClients; i++ { if _, err := e.createAndFillRandomMBox(cl); err != nil { return err } } - seqSets, err := NewParallelSeqSet(uint32(*flags.MessageCount), - *flags.ParallelClients, + seqSets, err := NewParallelSeqSet(uint32(*flags.IMAPMessageCount), + *flags.IMAPParallelClients, *expungeListFlag, *expungeAllFlag, - *flags.RandomSeqSetIntervals, + *flags.IMAPRandomSeqSetIntervals, true, - *flags.UIDMode) + *flags.IMAPUIDMode) if err != nil { return err @@ -92,7 +92,7 @@ func (e *Expunge) TearDown(ctx context.Context, addr net.Addr) error { func (e *Expunge) Run(ctx context.Context, addr net.Addr) error { RunParallelClientsWithMailboxes(addr, e.mboxInfo, func(cl *client.Client, index uint) { var expungeFn func(*client.Client, *imap.SeqSet) error - if *flags.UIDMode { + if *flags.IMAPUIDMode { expungeFn = func(cl *client.Client, set *imap.SeqSet) error { if err := UIDStore(cl, set, "+FLAGS", true, imap.DeletedFlag); err != nil { return err diff --git a/benchmarks/gluon_bench/imap_benchmarks/fetch.go b/benchmarks/gluon_bench/imap_benchmarks/fetch.go index 08c1c4fd..b2b38943 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/fetch.go +++ b/benchmarks/gluon_bench/imap_benchmarks/fetch.go @@ -12,10 +12,10 @@ import ( ) var ( - fetchCountFlag = flag.Uint("fetch-count", 0, "Total number of messages to fetch during fetch benchmarks.") - fetchListFlag = flag.String("fetch-list", "", "Use a list of predefined sequences to fetch rather than random generated.") - fetchReadOnly = flag.Bool("fetch-read-only", false, "If set, perform fetches in read-only mode.") - fetchAllFlag = flag.Bool("fetch-all", false, "If set, perform one fetch for all messages.") + fetchCountFlag = flag.Uint("imap-fetch-count", 0, "Total number of messages to fetch during fetch benchmarks.") + fetchListFlag = flag.String("imap-fetch-list", "", "Use a list of predefined sequences to fetch rather than random generated.") + fetchReadOnly = flag.Bool("imap-fetch-read-only", false, "If set, perform fetches in read-only mode.") + fetchAllFlag = flag.Bool("imap-fetch-all", false, "If set, perform one fetch for all messages.") ) type Fetch struct { @@ -28,7 +28,7 @@ func NewFetch() benchmark.Benchmark { } func (*Fetch) Name() string { - return "fetch" + return "imap-fetch" } func (f *Fetch) Setup(ctx context.Context, addr net.Addr) error { @@ -39,16 +39,16 @@ func (f *Fetch) Setup(ctx context.Context, addr net.Addr) error { fetchCount := uint32(*fetchCountFlag) if fetchCount == 0 { - fetchCount = uint32(*flags.MessageCount) / 2 + fetchCount = uint32(*flags.IMAPMessageCount) / 2 } seqSets, err := NewParallelSeqSet(fetchCount, - *flags.ParallelClients, + *flags.IMAPParallelClients, *fetchListFlag, *fetchAllFlag, - *flags.RandomSeqSetIntervals, + *flags.IMAPRandomSeqSetIntervals, false, - *flags.UIDMode) + *flags.IMAPUIDMode) if err != nil { return err @@ -66,7 +66,7 @@ func (f *Fetch) TearDown(ctx context.Context, addr net.Addr) error { func (f *Fetch) Run(ctx context.Context, addr net.Addr) error { RunParallelClientsWithMailbox(addr, f.MBoxes[0], *fetchReadOnly, func(cl *client.Client, index uint) { var fetchFn func(*client.Client, *imap.SeqSet) error - if *flags.UIDMode { + if *flags.IMAPUIDMode { fetchFn = func(cl *client.Client, set *imap.SeqSet) error { return UIDFetchMessage(cl, set, imap.FetchAll) } diff --git a/benchmarks/gluon_bench/imap_benchmarks/imap_benchmark_runner.go b/benchmarks/gluon_bench/imap_benchmarks/imap_benchmark_runner.go index 6c304f87..c52777db 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/imap_benchmark_runner.go +++ b/benchmarks/gluon_bench/imap_benchmarks/imap_benchmark_runner.go @@ -75,8 +75,8 @@ func (i *IMAPBenchmarkRunner) TearDown(ctx context.Context) error { func NewIMAPBenchmarkRunner(bench IMAPBenchmark) benchmark.Benchmark { var serverBuilder server.ServerBuilder - if len(*flags.RemoteServer) != 0 { - builder, err := server.NewRemoteServerBuilder(*flags.RemoteServer) + if len(*flags.IMAPRemoteServer) != 0 { + builder, err := server.NewRemoteServerBuilder(*flags.IMAPRemoteServer) if err != nil { panic(fmt.Sprintf("Invalid Server address: %v", err)) } diff --git a/benchmarks/gluon_bench/imap_benchmarks/move.go b/benchmarks/gluon_bench/imap_benchmarks/move.go index c851b947..8cc2f5d1 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/move.go +++ b/benchmarks/gluon_bench/imap_benchmarks/move.go @@ -14,9 +14,9 @@ import ( ) var ( - moveListFlag = flag.String("move-list", "", "Use a list of predefined sequences to move rather than random generated.") - moveAllFlag = flag.Bool("move-all", false, "If set, perform a move of the all messages.") - moveIntoSameDstFlag = flag.Bool("move-into-same-dst", false, "If set, rather than moving each unique mailbox into separate unique mailboxes, move all messages into one common destination mailbox.") + moveListFlag = flag.String("imap-move-list", "", "Use a list of predefined sequences to move rather than random generated.") + moveAllFlag = flag.Bool("imap-move-all", false, "If set, perform a move of the all messages.") + moveIntoSameDstFlag = flag.Bool("imap-move-into-same-dst", false, "If set, rather than moving each unique mailbox into separate unique mailboxes, move all messages into one common destination mailbox.") ) type Move struct { @@ -32,19 +32,19 @@ func NewMove() benchmark.Benchmark { } func (*Move) Name() string { - return "move" + return "imap-move" } func (m *Move) Setup(ctx context.Context, addr net.Addr) error { - if *flags.MessageCount == 0 { + if *flags.IMAPMessageCount == 0 { return fmt.Errorf("move benchmark requires a message count > 0") } return WithClient(addr, func(cl *client.Client) error { - m.srcMailboxes = make([]string, 0, *flags.ParallelClients) - m.dstMailboxes = make([]string, 0, *flags.ParallelClients) + m.srcMailboxes = make([]string, 0, *flags.IMAPParallelClients) + m.dstMailboxes = make([]string, 0, *flags.IMAPParallelClients) - for i := uint(0); i < *flags.ParallelClients; i++ { + for i := uint(0); i < *flags.IMAPParallelClients; i++ { mbox, err := m.createAndFillRandomMBox(cl) if err != nil { return err @@ -57,7 +57,7 @@ func (m *Move) Setup(ctx context.Context, addr net.Addr) error { if *moveIntoSameDstFlag { dstMboxCount = 1 } else { - dstMboxCount = *flags.ParallelClients + dstMboxCount = *flags.IMAPParallelClients } for i := uint(0); i < dstMboxCount; i++ { @@ -69,13 +69,13 @@ func (m *Move) Setup(ctx context.Context, addr net.Addr) error { m.dstMailboxes = append(m.dstMailboxes, mbox) } - seqSets, err := NewParallelSeqSet(uint32(*flags.MessageCount), - *flags.ParallelClients, + seqSets, err := NewParallelSeqSet(uint32(*flags.IMAPMessageCount), + *flags.IMAPParallelClients, *moveListFlag, *moveAllFlag, - *flags.RandomSeqSetIntervals, + *flags.IMAPRandomSeqSetIntervals, true, - *flags.UIDMode) + *flags.IMAPUIDMode) if err != nil { return err @@ -101,7 +101,7 @@ func (m *Move) Run(ctx context.Context, addr net.Addr) error { RunParallelClientsWithMailboxes(addr, mboxInfos, func(cl *client.Client, index uint) { var moveFn func(*client.Client, *imap.SeqSet, string) error - if *flags.UIDMode { + if *flags.IMAPUIDMode { moveFn = func(cl *client.Client, set *imap.SeqSet, mailbox string) error { return cl.UidMove(set, mailbox) } diff --git a/benchmarks/gluon_bench/imap_benchmarks/search.go b/benchmarks/gluon_bench/imap_benchmarks/search.go index 9d94189f..73e6db49 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/search.go +++ b/benchmarks/gluon_bench/imap_benchmarks/search.go @@ -17,9 +17,9 @@ import ( "github.com/emersion/go-imap/client" ) -var searchCountFlag = flag.Uint("search-count", 0, "Total number of messages to search during search benchmarks.") -var searchTextListFlag = flag.String("search-text-list", "", "Use a list of new line separate search queries instead instead of the default list.") -var searchSinceListFlag = flag.String("search-since-list", "", "Use a list of new line dates instead of random generated.") +var searchCountFlag = flag.Uint("imap-search-count", 0, "Total number of messages to search during search benchmarks.") +var searchTextListFlag = flag.String("imap-search-text-list", "", "Use a list of new line separate search queries instead instead of the default list.") +var searchSinceListFlag = flag.String("imap-search-since-list", "", "Use a list of new line dates instead of random generated.") type SearchQuery interface { Name() string @@ -51,7 +51,7 @@ func (s *Search) Setup(ctx context.Context, addr net.Addr) error { searchCount := uint32(*searchCountFlag) if searchCount == 0 { - searchCount = uint32(*flags.MessageCount) / 2 + searchCount = uint32(*flags.IMAPMessageCount) / 2 } if err := s.query.Setup(ctx, cl, searchCount); err != nil { @@ -88,7 +88,7 @@ type SearchTextQuery struct { } func (s *SearchTextQuery) Name() string { - return "search-text" + return "imap-search-text" } func (s *SearchTextQuery) Setup(ctx context.Context, cl *client.Client, searchCount uint32) error { @@ -140,7 +140,7 @@ type SearchSinceQuery struct { } func (*SearchSinceQuery) Name() string { - return "search-since" + return "imap-search-since" } func (s *SearchSinceQuery) Setup(ctx context.Context, cl *client.Client, searchCount uint32) error { diff --git a/benchmarks/gluon_bench/imap_benchmarks/store.go b/benchmarks/gluon_bench/imap_benchmarks/store.go index 290ea4e9..7e0fc8d8 100644 --- a/benchmarks/gluon_bench/imap_benchmarks/store.go +++ b/benchmarks/gluon_bench/imap_benchmarks/store.go @@ -12,10 +12,10 @@ import ( ) var ( - storeCountFlag = flag.Uint("store-count", 0, "Total number of messages to store during store benchmarks.") - storeListFlag = flag.String("store-list", "", "Use a list of predefined sequences to store rather than random generated.") - storeSilentFlag = flag.Bool("store-silent", false, "When set to true, request silent updates that do not produce any responses") - storeAllFlag = flag.Bool("store-all", false, "If set, perform one store for all messages.") + storeCountFlag = flag.Uint("imap-store-count", 0, "Total number of messages to store during store benchmarks.") + storeListFlag = flag.String("imap-store-list", "", "Use a list of predefined sequences to store rather than random generated.") + storeSilentFlag = flag.Bool("imap-store-silent", false, "When set to true, request silent updates that do not produce any responses") + storeAllFlag = flag.Bool("imap-store-all", false, "If set, perform one store for all messages.") ) type StoreBench struct { @@ -28,7 +28,7 @@ func NewStore() benchmark.Benchmark { } func (*StoreBench) Name() string { - return "store" + return "imap-store" } func (s *StoreBench) Setup(ctx context.Context, addr net.Addr) error { @@ -39,16 +39,16 @@ func (s *StoreBench) Setup(ctx context.Context, addr net.Addr) error { storeCount := uint32(*storeCountFlag) if storeCount == 0 { - storeCount = uint32(*flags.MessageCount) / 2 + storeCount = uint32(*flags.IMAPMessageCount) / 2 } seqSets, err := NewParallelSeqSet(storeCount, - *flags.ParallelClients, + *flags.IMAPParallelClients, *storeListFlag, *storeAllFlag, - *flags.RandomSeqSetIntervals, + *flags.IMAPRandomSeqSetIntervals, false, - *flags.UIDMode) + *flags.IMAPUIDMode) if err != nil { return err @@ -70,7 +70,7 @@ func (s *StoreBench) Run(ctx context.Context, addr net.Addr) error { RunParallelClientsWithMailbox(addr, s.MBoxes[0], false, func(cl *client.Client, index uint) { var storeFn func(*client.Client, *imap.SeqSet, int) error - if *flags.UIDMode { + if *flags.IMAPUIDMode { storeFn = func(cl *client.Client, set *imap.SeqSet, index int) error { return UIDStore(cl, set, items[index%len(items)], *storeSilentFlag, flagList[index%len(flagList)]) }