summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Szyndela <adrian.s@samsung.com>2020-12-08 15:52:12 +0100
committerAdrian Szyndela <adrian.s@samsung.com>2020-12-11 10:12:21 +0100
commit55af0a46c935aabc7e8bfcd6822135910fc75085 (patch)
treef0dd96d2d2c3881decf29239e8e40e3095d0e90b
parentc97b4b2fc2282f2754e99bc70d00f0b194bbde30 (diff)
downloadlibdbuspolicy-55af0a46c935aabc7e8bfcd6822135910fc75085.tar.gz
libdbuspolicy-55af0a46c935aabc7e8bfcd6822135910fc75085.tar.bz2
libdbuspolicy-55af0a46c935aabc7e8bfcd6822135910fc75085.zip
tests: allow reading from file in perf test
Change-Id: I1660ed2a0248efe139590ac278fbf29d4db2d44c
-rw-r--r--src/stest_performance.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/stest_performance.cpp b/src/stest_performance.cpp
index 1fe6635..bda50f8 100644
--- a/src/stest_performance.cpp
+++ b/src/stest_performance.cpp
@@ -208,16 +208,17 @@ void run_x_times(std::function<void(void)> func, size_t times) {
std::cout << "run: " << static_cast<double>(end - begin)/CLOCKS_PER_SEC << std::endl;
}
-void run_fb(const char *conf_file, bool verify, size_t count, bool worst) {
+void run_fb(const char *conf_file, const std::string &serialized, bool verify, size_t count, bool worst) {
Serializer serializer;
- size_t size;
- auto buff = serializer.serialize(conf_file, size);
-
- if (verify)
- std::cerr << "verification not supported at the moment" << std::endl;
StorageBackendSerialized storage;
- storage.initFromData(buff, size);
+ if (serialized.empty()) {
+ size_t size;
+ auto buff = serializer.serialize(conf_file, size);
+ storage.initFromData(buff, size, verify);
+ } else {
+ storage.init(serialized.c_str(), verify);
+ }
printf("SERIALIZED:\n");
if (!worst)
@@ -226,8 +227,8 @@ void run_fb(const char *conf_file, bool verify, size_t count, bool worst) {
run_x_times([&storage](){ send_prefix_test(storage, test_send_to_nonexistent); }, count);
}
-void run_tests(const char *conf_file, bool verify, size_t c, bool worst) {
- run_fb(conf_file, verify, c, worst);
+void run_tests(const char *conf_file, const std::string &serialized, bool verify, size_t c, bool worst) {
+ run_fb(conf_file, serialized, verify, c, worst);
}
void print_help(const char *name) {
@@ -248,13 +249,14 @@ int main(int argc, char *argv[])
{
int c;
std::string input_filename = system_bus_conf_file_primary();
+ std::string input_filename_serialized;
size_t count = 100;
bool verify = false;
bool worst = false;
while (1) {
int option_index;
- c = getopt_long(argc, argv, "vwc:", options, &option_index);
+ c = getopt_long(argc, argv, "vwc:i:", options, &option_index);
if (c == -1)
break;
switch(c) {
@@ -271,6 +273,9 @@ int main(int argc, char *argv[])
case 'w':
worst = true;
break;
+ case 'i':
+ input_filename_serialized = optarg;
+ break;
}
}
@@ -282,7 +287,7 @@ int main(int argc, char *argv[])
}
tslog::init();
- run_tests(input_filename.c_str(), verify, count, worst);
+ run_tests(input_filename.c_str(), input_filename_serialized, verify, count, worst);
return 0;
}