/* On p.44 of Dasgupta, Papadimitriou, and Vazirani, they ugh about how “very * slow” it would be to use sequential search over a list of 250 IP * addresses, one page after they’re breezing over how RSA is * “simple”, “convenient”, and “elementary”. This program shows that * sequential searching over an array of 250 IP addresses takes about * 0.45μs on my netbook. RSA-2048, by contrast, is about * 110000μs to sign and 1500μs to verify on the same machine, * according to `openssl speed rsa`. */ #include #include enum { n_ips = 250 }; int main(int argc, char **argv) { int ips[n_ips]; int matches = 0; srandom(37); for (int i = 0; i < n_ips; i++) { ips[i] = random(); } for (int i = 0; i < 10000; i++) { for (int j = 0; j < n_ips; j++) { for (int k = 0; k < n_ips; k++) { if (ips[j] == ips[k]) { matches++; break; } } } } return matches; }