blob: 68c854492487f052dfbc054e40763f6aab2333b4 [file] [log] [blame]
{{/*
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
*/}}
#include <{{ .FidlInclude }}>
#include <ctf/tests/pkg/fidl/cpp/test/handle_util.h>
#include <perftest/perftest.h>
#include <vector>
#include "src/tests/benchmarks/fidl/driver_llcpp/echo_call_benchmark_util.h"
#include "src/tests/benchmarks/fidl/driver_llcpp/echo_call_sync_benchmark_util.h"
namespace {
{{ range .Benchmarks }}
{{- if .HandleDefs }}
std::vector<zx_handle_t> BuildHandles{{ .Name }}() {
return {{ .HandleDefs }};
}
{{ .Type }} BuildFromHandles{{ .Name }}(fidl::AnyArena& allocator, const std::vector<zx_handle_t>& handle_defs) {
{{ .ValueBuild }}
auto result = {{ .ValueVar }};
return result;
}
{{ .Type }} Build{{ .Name }}(fidl::AnyArena& allocator) {
return BuildFromHandles{{ .Name }}(allocator, BuildHandles{{ .Name }}());
}
{{- else }}
{{ .Type }} Build{{ .Name }}(fidl::AnyArena& allocator) {
{{ .ValueBuild }}
auto result = {{ .ValueVar }};
return result;
}
{{- end }}
bool BenchmarkEchoCall{{ .Name }}(perftest::RepeatState* state) {
return driver_benchmarks::EchoCallBenchmark<{{ .EchoCallProtocolType }}>(state, Build{{ .Name }});
}
bool BenchmarkEchoCallSync{{ .Name }}(perftest::RepeatState* state) {
return driver_benchmarks::EchoCallSyncBenchmark<{{ .EchoCallProtocolType }}>(state, Build{{ .Name }});
}
{{- end -}}
void RegisterTests() {
{{ range .Benchmarks }}
perftest::RegisterTest("DriverLLCPP/EchoCall/{{ .Path }}/Steps", BenchmarkEchoCall{{ .Name }});
perftest::RegisterTest("DriverLLCPP/EchoCallSync/{{ .Path }}/Steps", BenchmarkEchoCallSync{{ .Name }});
{{ end }}
}
PERFTEST_CTOR(RegisterTests)
} // namespace