I built two programs, one using malloc and other one using mmap. The execution time using mmap is much less than using malloc
malloc
mmap
mmap doesn't actually read the file. It just maps it to address space. That's why it's so fast, there is no disc I/O until you actually access that region of address space.
malloc is simply a mapping of address space to memory