[PATCH] D88590: [clangd] Add bencmark for measuring latency of DecisionForest model.

Utkarsh Saxena via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 30 10:04:52 PDT 2020


usaxena95 updated this revision to Diff 295338.
usaxena95 added a comment.

Minor fixes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88590/new/

https://reviews.llvm.org/D88590

Files:
  clang-tools-extra/clangd/benchmarks/CMakeLists.txt
  clang-tools-extra/clangd/benchmarks/DecisionForestBenchmark.cpp


Index: clang-tools-extra/clangd/benchmarks/DecisionForestBenchmark.cpp
===================================================================
--- /dev/null
+++ 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();
+}
Index: clang-tools-extra/clangd/benchmarks/CMakeLists.txt
===================================================================
--- clang-tools-extra/clangd/benchmarks/CMakeLists.txt
+++ 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88590.295338.patch
Type: text/x-patch
Size: 2745 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200930/dbc3f380/attachment.bin>


More information about the cfe-commits mailing list