Fastest String Search Algorithm.

Amit Choudhary amitchoudhary0523@gmail.com
Tue Jun 8 06:33:07 GMT 2021


> [1] https://github.com/bminor/glibc/blob/master/string/strstr.c
>

I downloaded this file and included "str-two-way.h" from glibc-2.33 source.

I tested the new / latest strstr() with my algorithm.

The text is around 60 KB long and the pattern is around 28 KB long.

The result is that my algorithm outperforms the latest strstr().

"""""My conclusion is that: For small patterns strstr() is faster but for
very long patterns my algorithm is faster."""""

If anyone needs the text / pattern or the source code for this test, then
please let me know.

Please check the results below:

========================================================
amit@amit-zorin-os:~/string_search$ ./a.out

Time taken by strstr() = 835,836

Time taken by choudhary_string_search_algorithm() = 258,305

Choudhary algorithm is faster than strstr().

amit@amit-zorin-os:~/string_search$
========================================================

Regards,
Amit


More information about the Libc-alpha mailing list