Files
kopia/cli/command_benchmark.go
Ricardo Pescuma Domenecci 0724511283 feat(repository): Error correction for blobs (#2270)
* Initial implementation of ecc using Encryptor interface

* Created benchmark ecc command

* Fixing the order inside the wrapper

* Removed rs_bw because it is always worse

* Fixing naming and adding more comments

* Different approaches depending of file size/space overhead

* Fixes requested in PR

* Fixed lint errors

* Fixes requested in the PR

* Fixed import order

* Fixed more lint errors
2022-08-09 18:24:25 -07:00

53 lines
1001 B
Go

package cli
import (
"sync"
)
type commandBenchmark struct {
compression commandBenchmarkCompression
crypto commandBenchmarkCrypto
hashing commandBenchmarkHashing
encryption commandBenchmarkEncryption
splitters commandBenchmarkSplitters
ecc commandBenchmarkEcc
}
func (c *commandBenchmark) setup(svc appServices, parent commandParent) {
cmd := parent.Command("benchmark", "Commands to test performance of algorithms.")
c.compression.setup(svc, cmd)
c.crypto.setup(svc, cmd)
c.splitters.setup(svc, cmd)
c.hashing.setup(svc, cmd)
c.encryption.setup(svc, cmd)
c.ecc.setup(svc, cmd)
}
type cryptoBenchResult struct {
hash string
encryption string
throughput float64
}
func runInParallel(parallel int, run func() interface{}) interface{} {
var wg sync.WaitGroup
for i := 0; i < parallel-1; i++ {
wg.Add(1)
go func() {
defer wg.Done()
run()
}()
}
// run one on the main goroutine and N-1 in parallel.
v := run()
wg.Wait()
return v
}