-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Refactor benchmark execution code
Refactor the benchmark execution code to allow for different type of benchmark scenarios. Currently, all benchmarks assume they will be run against an IMAP server. For the Sync benchmark, this is not the case. The new benchmark code makes no assumptions about what the benchmark does internally. All IMAP benchmarks now implement the IMAPBenchmark interface and the IMAPBenchmarkRunner ensures that all the previous state requirements are set properly for those benchmarks. Some other utility code has been moved to a more appropriate location as well.
- Loading branch information
1 parent
80806b4
commit 29af240
Showing
22 changed files
with
327 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package benchmark | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
// BenchDirConfig controls the directory where the benchmark data will be generated. | ||
type BenchDirConfig interface { | ||
Get() (string, error) | ||
} | ||
|
||
// FixedBenchDirConfig always returns a known path. | ||
type FixedBenchDirConfig struct { | ||
path string | ||
} | ||
|
||
func NewFixedBenchDirConfig(path string) *FixedBenchDirConfig { | ||
return &FixedBenchDirConfig{path: path} | ||
} | ||
|
||
func (p *FixedBenchDirConfig) Get() (string, error) { | ||
if err := os.MkdirAll(p.path, 0o777); err != nil { | ||
return "", err | ||
} | ||
|
||
return p.path, nil | ||
} | ||
|
||
// TmpBenchDirConfig returns a temporary path that is generated on first use. | ||
type TmpBenchDirConfig struct { | ||
path string | ||
} | ||
|
||
func (t *TmpBenchDirConfig) Get() (string, error) { | ||
if len(t.path) == 0 { | ||
path, err := os.MkdirTemp("", "gluon-bench-*") | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
t.path = path | ||
} | ||
|
||
return t.path, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package benchmark | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/ProtonMail/gluon/benchmarks/gluon_bench/reporter" | ||
) | ||
|
||
type Benchmark interface { | ||
// Name should return the name of the benchmark. It will also be used to match against cli args. | ||
Name() string | ||
|
||
// Setup sets up the benchmark state, this is not timed. | ||
Setup(ctx context.Context, benchmarkDir string) error | ||
|
||
// Run performs the actual benchmark, this is timed. | ||
Run(ctx context.Context) (*reporter.BenchmarkRun, error) | ||
|
||
// TearDown clear the benchmark state, this is not timed. | ||
TearDown(ctx context.Context) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
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.") | ||
Mailbox = flag.String("mailbox", "INBOX", "If not specified will use INBOX as the mailbox to run benchmarks against.") | ||
FillSourceMailbox = flag.Uint("fill-src-mailbox", 1000, "Number of messages to add to the source inbox before each benchmark, set to 0 to skip.") | ||
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.") | ||
) |
6 changes: 4 additions & 2 deletions
6
...hmarks/gluon_bench/utils/build_mailbox.go → ...on_bench/imap_benchmarks/build_mailbox.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.