Skip to content
Snippets Groups Projects
Select Git revision
  • 73c4b8a4b3d61b45131f75b2cc5ab9afbfc6686a
  • master default protected
  • image_support_for_boolean
  • image_support_lofar_fixes
  • image_support
  • moved-to-gitlab
  • remove-libpqxx-submodule
  • v0.11.2
  • v0.11.1
  • v0.11.0
  • v0.10.0
  • v0.9.1
  • v0.9.0
13 results

QueryBuilderTests.cpp

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    QueryBuilderTests.cpp 5.87 KiB
    /* Copyright (C) : 2014-2019
       European Synchrotron Radiation Facility
       BP 220, Grenoble 38043, FRANCE
    
       This file is part of libhdb++timescale.
    
       libhdb++timescale is free software: you can redistribute it and/or modify
       it under the terms of the Lesser GNU General Public License as published by
       the Free Software Foundation, either version 3 of the License, or
       (at your option) any later version.
    
       libhdb++timescale is distributed in the hope that it will be useful,
       but WITHOUT ANY WARRANTY; without even the implied warranty of
       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser
       GNU General Public License for more details.
    
       You should have received a copy of the Lesser GNU General Public License
       along with libhdb++timescale.  If not, see <http://www.gnu.org/licenses/>. */
    
    #include "QueryBuilder.hpp"
    
    #include <benchmark/benchmark.h>
    
    //=============================================================================
    //=============================================================================
    void bmAllocateQueryBuilder(benchmark::State &state)
    {
        // Test - Testing the time it takes to allocate a QueryBuilder, mainly for future test
        // reference
        hdbpp_internal::LogConfigurator::initLogging("test");
    
        for (auto _ : state)
            hdbpp_internal::pqxx_conn::QueryBuilder query_builder;
    }
    
    BENCHMARK(bmAllocateQueryBuilder);
    
    //=============================================================================
    //=============================================================================
    void bmTraitsComparator(benchmark::State &state)
    {
        // TEST - Test the AttributeTraits comparator used in the cache inside QueryBuilder,
        // the test is against a full map with every possible tango traits combination
        std::map<hdbpp_internal::AttributeTraits, std::string> trait_cache;
    
        vector<Tango::CmdArgType> types {Tango::DEV_DOUBLE,
            Tango::DEV_FLOAT,
            Tango::DEV_STRING,
            Tango::DEV_LONG,
            Tango::DEV_ULONG,
            Tango::DEV_LONG64,
            Tango::DEV_ULONG64,
            Tango::DEV_SHORT,
            Tango::DEV_USHORT,
            Tango::DEV_BOOLEAN,
            Tango::DEV_UCHAR,
            Tango::DEV_STATE,
            Tango::DEV_ENCODED,
            Tango::DEV_ENUM};
    
        vector<Tango::AttrWriteType> write_types {Tango::READ, Tango::WRITE, Tango::READ_WRITE, Tango::READ_WITH_WRITE};
        vector<Tango::AttrDataFormat> format_types {Tango::SCALAR, Tango::SPECTRUM, Tango::IMAGE};
    
        for (auto &type : types)
        {
            for (auto &format : format_types)
            {
                for (auto &write : write_types)
                {
                    // add to the cache for future hits