<commit_before>#include <celero/Celero.h>

#include <annis/query.h>
#include <annis/annosearch/exactannokeysearch.h>
#include <annis/operators/pointing.h>

using namespace annis;

CELERO_MAIN

class QueryFixture : public celero::TestFixture
{
    public:
        QueryFixture()
        {
        }

        /*
        virtual std::vector<std::pair<int64_t, uint64_t>> getExperimentValues() const override
        {
            std::vector<std::pair<int64_t, uint64_t>> problemSpace;
            problemSpace.push_back(std::make_pair(1, uint64_t(0)));

            return problemSpace;
        }
        */

        /// Before each run, build a vector of random integers.
        virtual void setUp(int64_t experimentValue)
        {
          char* testDataEnv = std::getenv("ANNIS4_TEST_DATA");
          std::string dataDir("data");
          if (testDataEnv != NULL) {
            dataDir = testDataEnv;
          }
          db.load(dataDir + "/GUM", true);
        }

        DB db;

        std::shared_ptr<Query> createQuery(QueryConfig config)
        {
          std::shared_ptr<Query> query = std::make_shared<Query>(db, config);

          query->addNode(std::make_shared<ExactAnnoKeySearch>(db, "pos"));
          query->addNode(std::make_shared<ExactAnnoKeySearch>(db, "pos"));

          Annotation edgeAnno = {db.strings.add("func"), 0, db.strings.add("dep")};
          query->addOperator(std::make_shared<Pointing>(db.edges, db.strings, "", "dep", edgeAnno), 0, 1);
          return query;
        }
};


BASELINE_F(Parallel, Baseline, QueryFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 1;
  std::shared_ptr<Query> query = createQuery(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(Parallel, N2, QueryFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 2;
  std::shared_ptr<Query> query = createQuery(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(Parallel, N3, QueryFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 3;
  std::shared_ptr<Query> query = createQuery(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(Parallel, N4, QueryFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 4;
  std::shared_ptr<Query> query = createQuery(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(Parallel, N5, QueryFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 5;
  std::shared_ptr<Query> query = createQuery(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(Parallel, N6, QueryFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 6;
  std::shared_ptr<Query> query = createQuery(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(Parallel, N7, QueryFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 7;
  std::shared_ptr<Query> query = createQuery(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(Parallel, N8, QueryFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 8;
  std::shared_ptr<Query> query = createQuery(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}
<commit_msg>Add a new query to the parallel benchmark.<commit_after>#include <celero/Celero.h>

#include <annis/query.h>
#include <annis/annosearch/exactannokeysearch.h>
#include <annis/annosearch/exactannovaluesearch.h>
#include <annis/annosearch/regexannosearch.h>

#include <annis/operators/pointing.h>
#include <annis/operators/precedence.h>

using namespace annis;

CELERO_MAIN

class GUMFixture : public celero::TestFixture
{
    public:
        GUMFixture()
        {
        }

        /*
        virtual std::vector<std::pair<int64_t, uint64_t>> getExperimentValues() const override
        {
            std::vector<std::pair<int64_t, uint64_t>> problemSpace;
            problemSpace.push_back(std::make_pair(1, uint64_t(0)));

            return problemSpace;
        }
        */

        /// Before each run, build a vector of random integers.
        virtual void setUp(int64_t experimentValue)
        {
          char* testDataEnv = std::getenv("ANNIS4_TEST_DATA");
          std::string dataDir("data");
          if (testDataEnv != NULL) {
            dataDir = testDataEnv;
          }
          db.load(dataDir + "/GUM", true);
        }

        DB db;

        std::shared_ptr<Query> query_PosDepPos(QueryConfig config)
        {
          std::shared_ptr<Query> query = std::make_shared<Query>(db, config);

          query->addNode(std::make_shared<ExactAnnoKeySearch>(db, "pos"));
          query->addNode(std::make_shared<ExactAnnoKeySearch>(db, "pos"));

          Annotation edgeAnno = {db.strings.add("func"), 0, db.strings.add("dep")};
          query->addOperator(std::make_shared<Pointing>(db.edges, db.strings, "", "dep", edgeAnno), 0, 1);
          return query;
        }

        std::shared_ptr<Query> query_UsedTo(QueryConfig config)
        {
          std::shared_ptr<Query> query = std::make_shared<Query>(db, config);

          query->addNode(std::make_shared<RegexAnnoSearch>(db, "pos", "NN.*"));
          query->addNode(std::make_shared<ExactAnnoValueSearch>(db, "annis4_internal", "tok", "used"));
          query->addNode(std::make_shared<ExactAnnoValueSearch>(db, "annis4_internal", "tok", "to"));

          query->addOperator(std::make_shared<Precedence>(db, db.edges), 0, 1);
          query->addOperator(std::make_shared<Precedence>(db, db.edges), 1, 2);

          return query;
        }

};


BASELINE_F(PosDepPos, Baseline, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 1;
  std::shared_ptr<Query> query = query_PosDepPos(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(PosDepPos, N2, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 2;
  std::shared_ptr<Query> query = query_PosDepPos(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(PosDepPos, N3, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 3;
  std::shared_ptr<Query> query = query_PosDepPos(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(PosDepPos, N4, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 4;
  std::shared_ptr<Query> query = query_PosDepPos(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(PosDepPos, N5, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 5;
  std::shared_ptr<Query> query = query_PosDepPos(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(PosDepPos, N6, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 6;
  std::shared_ptr<Query> query = query_PosDepPos(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(PosDepPos, N7, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 7;
  std::shared_ptr<Query> query = query_PosDepPos(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(PosDepPos, N8, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 8;
  std::shared_ptr<Query> query = query_PosDepPos(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BASELINE_F(UsedTo, Baseline, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 1;
  std::shared_ptr<Query> query = query_UsedTo(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(UsedTo, N2, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 2;
  std::shared_ptr<Query> query = query_UsedTo(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(UsedTo, N3, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 3;
  std::shared_ptr<Query> query = query_UsedTo(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(UsedTo, N4, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 4;
  std::shared_ptr<Query> query = query_UsedTo(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(UsedTo, N5, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 5;
  std::shared_ptr<Query> query = query_UsedTo(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(UsedTo, N6, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 6;
  std::shared_ptr<Query> query = query_UsedTo(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(UsedTo, N7, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 7;
  std::shared_ptr<Query> query = query_UsedTo(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

BENCHMARK_F(UsedTo, N8, GUMFixture, 10, 100)
{
  QueryConfig config;
  config.numOfParallelTasks = 8;
  std::shared_ptr<Query> query = query_UsedTo(config);
  int counter=0;
  while(query->next()) {
    counter++;
  }
}

{'fraction_non_alphanumeric': 0.14490875715365512, 'fraction_numerical': 0.024943310657596373, 'mean_word_length': 3.587419514611194, 'pattern_counts': {'":': 0, '<': 66, '<?xml version=': 0, '>': 101, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6517597', 'n_tokens_mistral': 3495, 'n_tokens_neox': 3329, 'n_words': 591}