This is a non-strict benchmark to compare the performance of pattern search.
Purpose: Find a pattern in a string and return the first position.
Example: the pattern "aba" can be found in "kkaba" and return 2.
Methods:
- C-naive (brute)
- C-KMP (good)
- CPP - string.find() method.
Results Format: POSITION_FOUND:TIME_CONSUMED
Command Format: EXE_PATH FILE_PATH E.g. ./a.out test.txt
How-to:
- clone or fork this repo.
- g++ *.cpp -O3 -Wall (Options are optional)
- ./a.out test.txt
NOTE:
- I would rather try different optimisations flags to check which has the best performance: -Os, -Ofast, -O2, -O3.
- The Static Analysis Script uses Clang
On Windows:
- Run the Scripts/Windows/Build.bat for building executables for different optimisations levels
- The build file is customizable so choose your own standard version and the output folder
Static Analysis using Clang
- Run Scripts/Windows/StaticAnalysis.bat
TODO:
- Read two files one containing the string to search for and the other contains the tests
- Improve Tests to showcase the performance of each algorithm
- Make Two Modes: Line-By-Line Mode && Whole Text Mode
- add other algorithms
- follow the static analysis guidelines and fix code accordingly
- implement a new version of each algorithm where it uses arena allocation instead of malloc/calloc