Last active
January 29, 2017 02:09
-
-
Save schwern/817105c33a27d225fa453f5017974c8f to your computer and use it in GitHub Desktop.
C program for https://stackoverflow.com/questions/41864011/associative-arrays-python-vs-perl-vs-awk-performace/41865056#41865056
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 <math.h> | |
#include <stdio.h> | |
#include <stdbool.h> | |
#include <stdlib.h> | |
static inline bool flip() { | |
return rand() % 2 ? true : false; | |
} | |
int main() { | |
for(int i = 1; i <= 400000000; i++) { | |
const char *key1 = flip() ? "NM" : "XR"; | |
const char *key2 = flip() ? "NM" : "XR"; | |
const int num1 = rand() % 10000000; | |
const int num2 = rand() % 10000000; | |
int num3 = rand(); | |
if( flip() ) { | |
num3 *= -1; | |
} | |
printf( | |
"%s_%d,%s_%d,%d\n", | |
key1, num1, | |
key2, num2, | |
num3 | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment