Skip to content

MyNameIsTrez/array-vs-malloc-profiling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Array vs malloc() profiling

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:

The output after running the program

Running

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages