9#include "../index/Serialization.h"
10#include "../index/dex/Dex.h"
11#include "benchmark/benchmark.h"
12#include "llvm/ADT/SmallVector.h"
13#include "llvm/ADT/StringRef.h"
14#include "llvm/Support/Path.h"
15#include "llvm/Support/Regex.h"
25std::unique_ptr<SymbolIndex> buildMem() {
30std::unique_ptr<SymbolIndex> buildDex() {
36std::vector<FuzzyFindRequest> extractQueriesFromLogs() {
41 <<
": " << Buffer.getError().message() <<
"\n";
45 StringRef
Log = Buffer.get()->getBuffer();
47 std::vector<FuzzyFindRequest> Requests;
48 auto JSONArray = llvm::json::parse(
Log);
52 llvm::errs() <<
"Error when parsing JSON requests file: "
53 << llvm::toString(JSONArray.takeError());
56 if (!JSONArray->getAsArray()) {
57 llvm::errs() <<
"Error: top-level value is not a JSON array: " <<
Log
62 for (
const auto &Item : *JSONArray->getAsArray()) {
63 FuzzyFindRequest Request;
65 llvm::json::Path::Root
Root(
"FuzzyFindRequest");
67 llvm::errs() << llvm::toString(
Root.getError()) <<
"\n";
68 Root.printErrorContext(Item, llvm::errs());
71 Requests.push_back(Request);
76static void memQueries(benchmark::State &State) {
77 const auto Mem = buildMem();
78 const auto Requests = extractQueriesFromLogs();
80 for (
const auto &Request : Requests)
81 Mem->fuzzyFind(Request, [](
const Symbol &S) {});
85static void dexQueries(benchmark::State &State) {
86 const auto Dex = buildDex();
87 const auto Requests = extractQueriesFromLogs();
89 for (
const auto &Request : Requests)
90 Dex->fuzzyFind(Request, [](
const Symbol &S) {});
94static void dexBuild(benchmark::State &State) {
108int main(
int argc,
char *argv[]) {
110 llvm::errs() <<
"Usage: " << argv[0]
111 <<
" global-symbol-index.dex requests.json "
112 "BENCHMARK_OPTIONS...\n";
122 ::benchmark::Initialize(&argc, argv);
123 ::benchmark::RunSpecifiedBenchmarks();
int main(int argc, char *argv[])
const char * IndexFilename
const char * RequestsFilename
std::unique_ptr< SymbolIndex > loadIndex(llvm::StringRef SymbolFilename, SymbolOrigin Origin, bool UseDex, bool SupportContainedRefs)
bool fromJSON(const llvm::json::Value &Parameters, FuzzyFindRequest &Request, llvm::json::Path P)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//