본문 바로가기
반응형

프로그래밍/C & C++13

원하는 시간(ms)이 지났는지 확인하는 class class명을 어떻게 지어야 하는지 몰라 그냥 TimeInterval로 지었음 정확하게 interval마다 무언가를 하는 것이 아니라.. interval 이상 지난 후 내가 뭘 해야 할 때 씀 처음 생성시 시간을 넣어주고 CheckInterval()을 계속 호출하면 생성시 넣어준 interval이 지나면 true를 return함 먼저 결과는.. # g++ time_interval.cpp -lgtest -lgtest_main -lpthread # ./a.out Running main() from gtest_main.cc [==========] Running 2 tests from 1 test case. [----------] Global test environment set-up. [----------] .. 2022. 3. 4.
rocksdb sample code on ubuntu 18.04 참고: https://techoverflow.net/2020/01/28/rocksdb-minimal-example-in-c/ RocksDB minimal example in C++ – TechOverflow This minimal example shows how to open a RocksDB database, write a key and how to read it. #include #include #include using namespace std; int main(int argc, char** argv) { rocksdb::DB* db; rocksdb::Options options; options.create_if_missing = true; rocksd techoverflow.net 1. 먼저 ro.. 2022. 2. 27.
fifo cache의 변형 fifo 정책을 따르긴하지만 쫓겨나는 item을 알고 이후 처리가 필요하여 구현 key-value이긴하지만 key가 2개여서 pair로 묶음 Push()에 의해 쫓겨나는 item은 return됨 #include #include #include #include #include #include #include "gtest/gtest.h" using namespace std; struct PairHash { template std::size_t operator () (const std::pair &p) const { return std::hash{}(p.first) ^ std::hash{}(p.second); } }; template class FifoCache { public: explicit FifoCac.. 2022. 2. 1.
ubuntu에 google test (gtest) 설치 후 간단히 test 먼저 소스 설치 sudo apt install libgtest-dev 혹시 cmake가 설치 되어 있지 않다면 cmake도 설치 sudo apt install cmake gtest 설치 cd /usr/src/gtest sudo mkdir build cd build sudo cmake .. sudo make sudo make install 간단한 code #include #include "gtest/gtest.h" using namespace std; TEST(test_name, test) { // test code } 간단히 build g++ test.cpp -lgtest -lgtest_main -lpthread 2022. 2. 1.
반응형