14#include "CompletionModel.h"
15#include "benchmark/benchmark.h"
16#include "llvm/ADT/StringRef.h"
23std::vector<Example> generateRandomDataset(
int NumExamples) {
24 auto FlipCoin = [&](
double Probability) {
25 return rand() % 1000 <= Probability * 1000;
27 auto RandInt = [&](
int Max) {
return rand() % Max; };
28 auto RandFloat = [&](
float Max = 1.0) {
29 return rand() % 1000 / 1000.0 * Max;
32 std::vector<Example> Examples;
33 Examples.reserve(NumExamples);
34 for (
int I = 0; I < NumExamples; ++I) {
36 E.setIsDeprecated(FlipCoin(0.1));
37 E.setIsReservedName(FlipCoin(0.1));
38 E.setIsImplementationDetail(FlipCoin(0.3));
39 E.setNumReferences(RandInt(10000));
40 E.setSymbolCategory(RandInt(10));
41 E.setNumNameInContext(RandInt(20));
42 E.setFractionNameInContext(RandFloat(1.0));
43 E.setIsNameInContext(FlipCoin(0.5));
44 E.setIsInBaseClass(FlipCoin(0.3));
45 E.setFileProximityDistanceCost(
46 FlipCoin(0.1) ? 999999
48 E.setSemaFileProximityScore(RandFloat(1));
49 E.setSymbolScopeDistanceCost(
50 FlipCoin(0.1) ? 999999
52 E.setSemaSaysInScope(FlipCoin(0.5));
53 E.setScope(RandInt(4));
54 E.setContextKind(RandInt(36));
55 E.setIsInstanceMember(FlipCoin(0.5));
56 E.setHadContextType(FlipCoin(0.6));
57 E.setHadSymbolType(FlipCoin(0.6));
58 E.setTypeMatchesPreferred(FlipCoin(0.5));
59 Examples.push_back(
E);
64void runDecisionForestPrediction(
const std::vector<Example> Examples) {
65 for (
const Example &
E : Examples)
69static void decisionForestPredict(benchmark::State &State) {
71 for (
auto _ : State) {
73 const std::vector<Example> Examples = generateRandomDataset(1000000);
75 runDecisionForestPrediction(Examples);
78BENCHMARK(decisionForestPredict);
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//