MCPcopy Index your code
hub / github.com/FunctionStream/function-stream / BenchmarkStressForBasicFunc

Function BenchmarkStressForBasicFunc

benchmark/bench_test.go:41–113  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

39)
40
41func BenchmarkStressForBasicFunc(b *testing.B) {
42 s, err := server.NewDefaultServer()
43 if err != nil {
44 b.Fatal(err)
45 }
46 svrCtx, svrCancel := context.WithCancel(context.Background())
47 go s.Run(svrCtx)
48 defer func() {
49 svrCancel()
50 }()
51
52 inputTopic := "test-input-" + strconv.Itoa(rand.Int())
53 outputTopic := "test-output-" + strconv.Itoa(rand.Int())
54 cfg := &pulsaradmin.Config{}
55 admin, err := pulsaradmin.NewClient(cfg)
56 if err != nil {
57 panic(err)
58 }
59 replicas := int32(5)
60 createTopic := func(t string) {
61 tn, err := utils.GetTopicName(t)
62 if err != nil {
63 panic(err)
64 }
65 err = admin.Topics().Create(*tn, int(replicas))
66 if err != nil {
67 panic(err)
68 }
69
70 }
71 createTopic(inputTopic)
72 createTopic(outputTopic)
73
74 pConfig := &perf.Config{
75 PulsarURL: "pulsar://localhost:6650",
76 RequestRate: 200000.0,
77 Func: &adminclient.ModelFunction{
78 Runtime: adminclient.ModelRuntimeConfig{
79 Type: common.WASMRuntime,
80 Config: map[string]interface{}{
81 common.RuntimeArchiveConfigKey: "../bin/example_basic.wasm",
82 },
83 },
84 Source: adminutils.MakePulsarSourceTubeConfig(inputTopic),
85 Sink: *adminutils.MakePulsarSinkTubeConfig(outputTopic),
86 Replicas: replicas,
87 },
88 }
89
90 b.ReportAllocs()
91
92 ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(30*time.Second))
93 defer cancel()
94
95 profile := b.Name() + ".pprof"
96 file, err := os.Create(profile)
97 if err != nil {
98 b.Fatal(err)

Callers

nothing calls this directly

Calls 5

NewDefaultServerFunction · 0.92
NewFunction · 0.92
RunMethod · 0.65
CloseMethod · 0.65
WaitForReadyMethod · 0.45

Tested by

no test coverage detected