Skip to content

LoyolaChicagoCode/processtree-cpp

Repository files navigation

build-test

Required tools

Dependencies

The project uses CMake's FetchContent to pull in appropriate versions of these dependencies at the source level during the build process.
This ensures that the dependencies are link-time compatible with the project itself.

Building

$ cmake -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 -DCMAKE_BUILD_TYPE=Release -S . -B build
$ cmake --build build

These compiler settings should find the installed compilers in a platform-independent way. The -DCMAKE_BUILD_TYPE=Release setting is optional and will turn on compile-time optimization for more realistic performance measurements.

(If using CLion, one can also set the compilers in a CMake profile or a toolchain.)

Running the program

$ ps -ef | ./build/bin/processtree

Running the tests

$ ./build/bin/processtree_tests

Preliminary insights

  • It's best to use FetchContent for portability across platforms and toolchains and ensure link-time compatibility between a project and its dependencies.
  • The spdlog source has a bundled version of fmt; one needs to compile it against the standalone source of fmt when using both.
  • Returning a process instance or passing it by reference as an out argument makes no noticeable performance difference.
  • Allocating a new vector<string> for each input line or converting it into an instance variable of the parser makes no noticeable performance difference.
  • scn::scan_list is an excellent replacement for strtok.
  • scn::getline is three orders of magnitude slower than std::getline: total execution time 20 sec vs. 0.1 sec for 10,000 lines of input.
  • cin.getline is quite a bit slower than std::getline: total execution time 16 sec vs 8 sec for 2m lines of input.
  • spdlog is extremely fast even when using the method calls instead of the compile-time macros.
  • stdio is still about three times as fast as the combination of {fmt} and std::getline.
  • There can be subtle language differences between clang++ and g++.
  • There can be major performance differences between clang++ and g++; e.g., on MacOs, code generated by clang++ is twice as fast as g++ (CMake release builds).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published