diff --git a/clang-tools-extra/clangd/benchmarks/CMakeLists.txt b/clang-tools-extra/clangd/benchmarks/CMakeLists.txt --- a/clang-tools-extra/clangd/benchmarks/CMakeLists.txt +++ b/clang-tools-extra/clangd/benchmarks/CMakeLists.txt @@ -7,3 +7,11 @@ clangDaemon LLVMSupport ) + +add_benchmark(DecisionForestBenchmark DecisionForestBenchmark.cpp) + +target_link_libraries(DecisionForestBenchmark + PRIVATE + clangDaemon + LLVMSupport + ) \ No newline at end of file diff --git a/clang-tools-extra/clangd/benchmarks/DecisionForestBenchmark.cpp b/clang-tools-extra/clangd/benchmarks/DecisionForestBenchmark.cpp new file mode 100644 --- /dev/null +++ b/clang-tools-extra/clangd/benchmarks/DecisionForestBenchmark.cpp @@ -0,0 +1,57 @@ +//===--- DecisionForestBenchmark.cpp - Benchmark for code completion ranking +//latency -----------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "CompletionModel.h" +#include "benchmark/benchmark.h" + +const char *IndexFilename; +const char *RequestsFilename; + +namespace clang { +namespace clangd { +namespace { +void RunDecisionForestPrediciton() { + Example E; + + // E.setIsDeprecated(Quality.Deprecated); + // E.setIsReservedName(Quality.ReservedName); + // E.setIsImplementationDetail(Quality.ImplementationDetail); + // E.setNumReferences(Quality.References); + // E.setSymbolCategory(Quality.Category); + + // E.setIsNameInContext(Derived.NameMatchesContext); + // E.setIsForbidden(Relevance.Forbidden); + // E.setIsInBaseClass(Relevance.InBaseClass); + // E.setFileProximityDistance(Derived.FileProximityDistance); + // E.setSemaFileProximityScore(Relevance.SemaFileProximityScore); + // E.setSymbolScopeDistance(Derived.ScopeProximityDistance); + // E.setSemaSaysInScope(Relevance.SemaSaysInScope); + // E.setScope(Relevance.Scope); + // E.setContextKind(Relevance.Context); + // E.setIsInstanceMember(Relevance.IsInstanceMember); + // E.setHadContextType(Relevance.HadContextType); + // E.setHadSymbolType(Relevance.HadSymbolType); + // E.setTypeMatchesPreferred(Relevance.TypeMatchesPreferred); + // E.setFilterLength(Relevance.FilterLength); + return Evaluate(E); +} +static void DecisionForestPredict(benchmark::State &State) { + for (auto _ : State) + RunDecisionForestPrediciton(); +} +BENCHMARK(DecisionForestPredict); + +} // namespace +} // namespace clangd +} // namespace clang + +int main(int argc, char *argv[]) { + ::benchmark::Initialize(&argc, argv); + ::benchmark::RunSpecifiedBenchmarks(); +}