ATLAS Offline Software
Loading...
Searching...
No Matches
columnar::TestUtils::UserConfiguration Struct Referencefinal

a struct holding user configuration for the PHYSLITE tests More...

#include <Configuration.h>

Collaboration diagram for columnar::TestUtils::UserConfiguration:

Public Member Functions

void loadFromFile (const std::string &filename)
 load configuration overrides from a JSON file

Static Public Member Functions

static UserConfiguration fromEnvironment ()
 create a UserConfiguration, loading from the file pointed to by the COLUMNAR_TEST_CONFIG environment variable

Public Attributes

std::chrono::seconds targetTime = std::chrono::seconds(5)
unsigned int batchSize = 1000
bool runToolTwice = false
bool skipShallowCopies = false
bool measureNonAccessForEmpty = false
 whether to measure non-retrieval for empty containers

Detailed Description

a struct holding user configuration for the PHYSLITE tests

Eventually I can hopefully make this configurable at runtime, but for now this should at least allow me to share the settings between different files, so that they don't need to be all in the same file.

Definition at line 32 of file PhysicsAnalysis/Columnar/ColumnarTestFixtures/ColumnarTestFixtures/Configuration.h.

Member Function Documentation

◆ fromEnvironment()

UserConfiguration columnar::TestUtils::UserConfiguration::fromEnvironment ( )
static

create a UserConfiguration, loading from the file pointed to by the COLUMNAR_TEST_CONFIG environment variable

If the environment variable is not set, returns defaults. If it is set but the file does not exist, throws an error.

Definition at line 40 of file Configuration.cxx.

41 {
42 UserConfiguration config;
43 const char *envPath = std::getenv ("COLUMNAR_TEST_CONFIG");
44 if (envPath != nullptr && envPath[0] != '\0')
45 config.loadFromFile (envPath);
46 return config;
47 }

◆ loadFromFile()

void columnar::TestUtils::UserConfiguration::loadFromFile ( const std::string & filename)

load configuration overrides from a JSON file

Only fields present in the JSON are overridden; others keep their defaults.

Definition at line 19 of file Configuration.cxx.

21 {
22 std::ifstream file (filename);
23 if (!file.is_open())
24 throw std::runtime_error ("failed to open configuration file: " + filename);
25
26 auto json = nlohmann::json::parse (file);
27
28 if (json.contains ("targetTime"))
29 targetTime = std::chrono::seconds (json["targetTime"].get<int>());
30 if (json.contains ("batchSize"))
31 batchSize = json["batchSize"].get<unsigned int>();
32 if (json.contains ("runToolTwice"))
33 runToolTwice = json["runToolTwice"].get<bool>();
34 if (json.contains ("skipShallowCopies"))
35 skipShallowCopies = json["skipShallowCopies"].get<bool>();
36 if (json.contains ("measureNonAccessForEmpty"))
37 measureNonAccessForEmpty = json["measureNonAccessForEmpty"].get<bool>();
38 }
nlohmann::json json
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
TFile * file

Member Data Documentation

◆ batchSize

unsigned int columnar::TestUtils::UserConfiguration::batchSize = 1000

◆ measureNonAccessForEmpty

bool columnar::TestUtils::UserConfiguration::measureNonAccessForEmpty = false

whether to measure non-retrieval for empty containers

Definition at line 47 of file PhysicsAnalysis/Columnar/ColumnarTestFixtures/ColumnarTestFixtures/Configuration.h.

◆ runToolTwice

bool columnar::TestUtils::UserConfiguration::runToolTwice = false

◆ skipShallowCopies

bool columnar::TestUtils::UserConfiguration::skipShallowCopies = false

◆ targetTime

std::chrono::seconds columnar::TestUtils::UserConfiguration::targetTime = std::chrono::seconds(5)

The documentation for this struct was generated from the following files: