[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 09:56:02 PDT 2020


usaxena95 created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, mgorny.
Herald added a project: clang.
usaxena95 requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

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,59 @@
+//===--- IndexBenchmark.cpp - Clangd index benchmarks -----------*- 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 RunDecisionForestPredicitons() {
+  constexpr int NumExperiments = 10000;
+  for (int I = 0; I < NumExperiments; ++I) {
+    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 DexBuild(benchmark::State &State) {
+  for (auto _ : State)
+    RunDecisionForestPredicitons();
+}
+BENCHMARK(DexBuild);
+
+} // 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.295334.patch
Type: text/x-patch
Size: 2764 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200930/e292bf75/attachment.bin>


More information about the cfe-commits mailing list