diff options
author | Valery Piashchynski <[email protected]> | 2020-10-19 14:01:59 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-10-19 14:01:59 +0300 |
commit | 77670fb7af0c892c9b3a589fd424534fad288e7a (patch) | |
tree | 3adcaa85db664a355abe2b28f1d7e4a3fc45689f /pipe_factory_test.go | |
parent | 16fbf3104c3c34bd9355593052b686acd26a8efe (diff) |
Update according activity worker
Diffstat (limited to 'pipe_factory_test.go')
-rw-r--r-- | pipe_factory_test.go | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/pipe_factory_test.go b/pipe_factory_test.go index 93d9ccd8..4eda21a6 100644 --- a/pipe_factory_test.go +++ b/pipe_factory_test.go @@ -101,7 +101,7 @@ func Test_Pipe_Echo(t *testing.T) { t.Fatal(err) } - res, err := sw.Exec(ctx, Payload{Body: []byte("hello")}) + res, err := sw.ExecWithContext(ctx, Payload{Body: []byte("hello")}) assert.NoError(t, err) assert.NotNil(t, res) @@ -129,7 +129,7 @@ func Test_Pipe_Broken(t *testing.T) { t.Fatal(err) } - res, err := sw.Exec(ctx, Payload{Body: []byte("hello")}) + res, err := sw.ExecWithContext(ctx, Payload{Body: []byte("hello")}) assert.Error(t, err) assert.Nil(t, res.Body) @@ -178,7 +178,7 @@ func Benchmark_Pipe_Worker_ExecEcho(b *testing.B) { }() for n := 0; n < b.N; n++ { - if _, err := sw.Exec(context.Background(), Payload{Body: []byte("hello")}); err != nil { + if _, err := sw.ExecWithContext(context.Background(), Payload{Body: []byte("hello")}); err != nil { b.Fail() } } @@ -192,18 +192,6 @@ func Benchmark_Pipe_Worker_ExecEcho3(b *testing.B) { b.Fatal(err) } - //go func() { - // for { - // select { - // case event := <-w.Events(): - // b.Fatal(event) - // } - // } - // //err := w.Wait() - // //if err != nil { - // // b.Errorf("error waiting the WorkerProcess: error %v", err) - // //} - //}() defer func() { err = w.Stop(ctx) if err != nil { @@ -217,8 +205,35 @@ func Benchmark_Pipe_Worker_ExecEcho3(b *testing.B) { } for n := 0; n < b.N; n++ { - if _, err := sw.Exec(ctx, Payload{Body: []byte("hello")}); err != nil { + if _, err := sw.ExecWithContext(ctx, Payload{Body: []byte("hello")}); err != nil { b.Fail() } } } + +func Benchmark_Pipe_Worker_ExecEchoWithoutContext(b *testing.B) { + cmd := exec.Command("php", "tests/client.php", "echo", "pipes") + ctx := context.Background() + w, err := NewPipeFactory().SpawnWorkerWithContext(ctx, cmd) + if err != nil { + b.Fatal(err) + } + + defer func() { + err = w.Stop(ctx) + if err != nil { + b.Errorf("error stopping the WorkerProcess: error %v", err) + } + }() + + sw, err := NewSyncWorker(w) + if err != nil { + b.Fatal(err) + } + + for n := 0; n < b.N; n++ { + if _, err := sw.Exec(Payload{Body: []byte("hello")}); err != nil { + b.Fail() + } + } +}
\ No newline at end of file |