I built two programs, one using malloc and other one using mmap. The execution time using mmap is much less than using malloc
I assume that you are referring to using mmap and malloc for reading data from files. In that case you pretty much got the main point:
fread/fwrite you have to make many calls to the OS.mmap you appear to get access to the entire file in one operation. This is not entirely true because the OS probably maps the file one memory page at a time, but it is still a lot faster.