Created
September 17, 2012 13:44
-
-
Save wangzaixiang/3737341 to your computer and use it in GitHub Desktop.
Call Write API 1M Count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <sys/time.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
main(){ | |
struct timeval tv1, tv2; | |
gettimeofday(&tv1, NULL); | |
int fd = open("/dev/null", O_WRONLY); | |
char ch = 'H'; | |
for(int i=0; i<8000000; i++){ | |
write(fd, &ch, 1); | |
} | |
gettimeofday(&tv2, NULL); | |
printf("total time = %d\n", (tv2.tv_sec-tv1.tv_sec)*1000000+(tv2.tv_usec-tv1.tv_usec)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment