Created
October 11, 2016 21:26
-
-
Save lucas-clemente/437f93c71e600437b27d6996dead17f4 to your computer and use it in GitHub Desktop.
This file contains 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 <string.h> | |
#include <stdlib.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/in.h> | |
int sink; | |
void doSomething() { | |
for (int i = 0; i < 1000000; ++i) { | |
sink += i; | |
} | |
} | |
int main() { | |
struct sockaddr_in sa; | |
memset(&sa, 0, sizeof(sa)); | |
sa.sin_family = AF_INET; | |
sa.sin_port = htons(4242); | |
sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); | |
int fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); | |
int len = 1000; | |
void* buf = malloc(len); | |
for (int i = 0; i < 1000; i++) { | |
sendto(fd, buf, len, 0, &sa, sizeof(sa)); | |
doSomething(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment