Here are my 2 different implementations of LFU cache and implementation of "Perfect" cache(Cache, awared of future queries).
To build the project, you need to execute the following commands:
cd Cache
mkdir build
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release
make --directory=build
You will executables:
- LFU_hashmap - O(1) realisation of LFU
- perfect_cache - realisation of perfect cache
In this repository you can also find Python script for test generation and Shellscript for answers generation.
To compile LFU_hashmap and compare its performance with Perfect cache, enter the following command:
# -----------------------------v Any executable name could be here
./test_gen/test_and_compare.sh LFU_hashmap
You can generate any amount (10 as example) of tests by:
mkdir tests
./test_get/gen_tests.py
> 10
After that, you can run tests on executable by:
./test_gen/run_tests.sh <amount_of_tests> <path_to_exec> <path_to_ans_folder>
# example: ./run_tests.sh 10 ../LFU/build/perfect_cache ./perfect
To compare answers, you need to execute the following script
#/test_gen/
./compare.sh <tests_amount> <path_to_ans1_folder> <path_to_ans2_folder>
# example: ./compare.sh 9 ./tests/perfect ./tests/native
I learned a lot of new C++ mechanics, thanks to this project. You can read more about O(1) realisation of LFU cache here: http://dhruvbird.com/lfu.pdf