SDDS ToolKit Programs and Libraries for C and Python
Loading...
Searching...
No Matches
benchmark_sdds3.cc File Reference

Detailed Description

Comparable serial C and C++ SDDS benchmark workloads.

Measures full and selective reads, page seeks, writes, append and update operations, strings, arrays, and compressed streams using equivalent C and C++ workloads.

License
This file is distributed under the terms of the Software License Agreement found in the file LICENSE included with this distribution.

Definition in file benchmark_sdds3.cc.

#include "SDDS.hpp"
#include "SDDS.h"
#include <chrono>
#include <cmath>
#include <cstdint>
#include <filesystem>
#include <iostream>
#include <string>
#include <vector>
#include <sys/resource.h>

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 360 of file benchmark_sdds3.cc.

360 {
361 if (argc < 3) {
362 std::cerr << "usage: benchmark_sddspp MODE PATH [ROWS]\n";
363 return 2;
364 }
365 const std::string mode(argv[1]);
366 const std::filesystem::path path(argv[2]);
367 const std::int64_t rows = argc > 3 ? std::stoll(argv[3]) : 100000;
368 if (!path.parent_path().empty()) std::filesystem::create_directories(path.parent_path());
369 if (mode == "generate") {
370 generateCpp(path, rows);
371 return 0;
372 }
373 if (mode == "generate-gzip") {
374 generateCpp(path, rows, sdds::Compression::Gzip);
375 return 0;
376 }
377 if (mode == "generate-xz") {
378 generateCpp(path, rows, sdds::Compression::Xz);
379 return 0;
380 }
381 if (mode == "generate-mixed") {
382 generateMixed(path, rows);
383 return 0;
384 }
385 const auto start = std::chrono::steady_clock::now();
386 double checksum = NAN;
387 std::string engine;
388 std::string workload;
389 if (mode.rfind("cpp-", 0) == 0) {
390 engine = "cpp";
391 workload = mode.substr(4);
392 if (workload == "full" || workload == "project" || workload == "sparse" ||
393 workload == "compression")
394 checksum = cppRead(path, workload == "compression" ? "full" : workload);
395 else if (workload == "strings" || workload == "arrays")
396 checksum = cppMixedRead(path, workload == "strings");
397 else if (workload == "seek") checksum = cppSeek(path);
398 else if (workload == "write") checksum = cppWrite(path, rows);
399 else if (workload == "append") checksum = cppAppend(path);
400 else if (workload == "update") checksum = cppUpdate(path);
401 } else if (mode.rfind("c-", 0) == 0) {
402 engine = "c";
403 workload = mode.substr(2);
404 if (workload == "full" || workload == "project" || workload == "sparse" ||
405 workload == "compression")
406 checksum = cRead(path, workload == "compression" ? "full" : workload);
407 else if (workload == "strings" || workload == "arrays")
408 checksum = cMixedRead(path, workload == "strings");
409 else if (workload == "seek") checksum = cSeek(path);
410 else if (workload == "write") checksum = cWrite(path, rows);
411 else if (workload == "append") checksum = cAppend(path);
412 else if (workload == "update") checksum = cUpdate(path);
413 }
414 if (engine.empty() || std::isnan(checksum)) return 2;
415 const double seconds = std::chrono::duration<double>(
416 std::chrono::steady_clock::now() - start).count();
417 result(engine, workload, seconds, checksum);
418 return 0;
419}