This repository was created to support my blog post titled Static arrays are the best vectors.
main.c
contains tests that show that growing static or global arrays is pretty much just as fast as growing a local or global malloc()
ed array:
You can try the program on godbolt here, though note that due to godbolt's memory restrictions, the #define SIZE
has been set to 69 MB. This is fine however, since we see the same results with such a small size, but just scaled down.
You can reproduce this repository's screenshot where SIZE
was set to 1 GB by running this:
gcc main.c -Wall -Wextra -Werror -Wpedantic -Wfatal-errors -Ofast -march=native && ./a.out