Skip to content

Commit

Permalink
Start benchmark timer after OT.Init{Sender,Receiver}().
Browse files Browse the repository at this point in the history
  • Loading branch information
markkurossi committed Feb 18, 2023
1 parent b437cc8 commit a5229e9
Showing 1 changed file with 25 additions and 32 deletions.
57 changes: 25 additions & 32 deletions ot/ot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,14 @@ func benchmarkOT(sender, receiver OT, batchSize int, b *testing.B) {

pipe, rPipe := NewPipe()

b.ResetTimer()

go func(pipe *Pipe) {
err := receiver.InitReceiver(pipe)
if err != nil {
done <- err
pipe.Close()
return
}
for i := 0; i < b.N; i++ {
err := receiver.InitReceiver(pipe)
if err != nil {
done <- err
pipe.Close()
return
}
err = receiver.Receive(flags, labels)
if err != nil {
done <- err
Expand All @@ -161,62 +159,57 @@ func benchmarkOT(sender, receiver OT, batchSize int, b *testing.B) {
done <- nil
}(rPipe)

err := sender.InitSender(pipe)
if err != nil {
b.Fatalf("InitSender: %v", err)
}
b.ResetTimer()

for i := 0; i < b.N; i++ {
err := sender.InitSender(pipe)
if err != nil {
b.Fatalf("InitSender: %v", err)
}
err = sender.Send(wires)
if err != nil {
b.Fatalf("Send: %v", err)
}
}

err := <-done
err = <-done
if err != nil {
b.Errorf("receiver failed: %v", err)
}
}

func BenchmarkOTCO1(b *testing.B) {
func BenchmarkOTCO_1(b *testing.B) {
benchmarkOT(NewCO(), NewCO(), 1, b)
}

func XBenchmarkOTCO2(b *testing.B) {
benchmarkOT(NewCO(), NewCO(), 2, b)
}

func XBenchmarkOTCO4(b *testing.B) {
benchmarkOT(NewCO(), NewCO(), 4, b)
}

func BenchmarkOTCO8(b *testing.B) {
func BenchmarkOTCO_8(b *testing.B) {
benchmarkOT(NewCO(), NewCO(), 8, b)
}

func BenchmarkOTCO16(b *testing.B) {
func BenchmarkOTCO_16(b *testing.B) {
benchmarkOT(NewCO(), NewCO(), 16, b)
}

func BenchmarkOTCO32(b *testing.B) {
func BenchmarkOTCO_32(b *testing.B) {
benchmarkOT(NewCO(), NewCO(), 32, b)
}

func BenchmarkOTCO64(b *testing.B) {
func BenchmarkOTCO_64(b *testing.B) {
benchmarkOT(NewCO(), NewCO(), 64, b)
}

func XBenchmarkOTCO128(b *testing.B) {
benchmarkOT(NewCO(), NewCO(), 128, b)
}

func benchmarkOTRSA(keySize, batchSize int, b *testing.B) {
benchmarkOT(NewRSA(keySize), NewRSA(keySize), batchSize, b)
}

func BenchmarkOTRSA2048_1(b *testing.B) {
func BenchmarkOTRSA_2048_1(b *testing.B) {
benchmarkOTRSA(2048, 1, b)
}
func BenchmarkOTRSA2048_8(b *testing.B) {

func BenchmarkOTRSA_2048_8(b *testing.B) {
benchmarkOTRSA(2048, 8, b)
}

func BenchmarkOTRSA_2048_64(b *testing.B) {
benchmarkOTRSA(2048, 64, b)
}

0 comments on commit a5229e9

Please sign in to comment.