Skip to content

Instantly share code, notes, and snippets.

@dotwaffle
Created June 13, 2017 06:33
Show Gist options
  • Save dotwaffle/3a2db4e2cc539944fae2d1b5c1802539 to your computer and use it in GitHub Desktop.
Save dotwaffle/3a2db4e2cc539944fae2d1b5c1802539 to your computer and use it in GitHub Desktop.
How fast is bgpq3?
6:28:31 [dotwaffle@engelbert:~/go/src/github.com/dotwaffle/prefixlister] master* ± time bgpq3 AS-SET-LONAP-CONNECTED | wc
1100231 5501154 44853809
bgpq3 AS-SET-LONAP-CONNECTED 2.74s user 0.26s system 46% cpu 6.489 total
wc 0.95s user 0.03s system 15% cpu 6.489 total
6.489s is the time to beat it seems. Let's try mine:
6:28:42 [dotwaffle@engelbert:~/go/src/github.com/dotwaffle/prefixlister] master* ± time prefixlister AS-SET-LONAP-CONNECTED | wc
1100332 1100332 17349652
prefixlister AS-SET-LONAP-CONNECTED 7.84s user 1.01s system 95% cpu 9.217 total
wc 0.40s user 0.69s system 11% cpu 9.216 total
9.216s? BUT THAT'S SLOWER! Oh, fiddlesticks. Ok, let's activate "speed-mode" which disables the slowest bits of the code -- giving the right results, but not sorting or deduplicating prefixes
6:29:06 [dotwaffle@engelbert:~/go/src/github.com/dotwaffle/prefixlister] master* ± time prefixlister -speed-mode AS-SET-LONAP-CONNECTED | wc
1582255 1582255 24960151
prefixlister -speed-mode AS-SET-LONAP-CONNECTED 2.00s user 0.28s system 57% cpu 3.998 total
wc 0.44s user 0.02s system 11% cpu 3.996 total
6:29:19 [dotwaffle@engelbert:~/go/src/github.com/dotwaffle/prefixlister] master* ±
3.998s? WINNAR! Way faster than the slow coach! What if we then pipe it through Unix sort?
6:31:11 [dotwaffle@engelbert:~/go/src/github.com/dotwaffle/prefixlister] master* ± time prefixlister -speed-mode AS-SET-LONAP-CONNECTED | sort -u | wc
1100332 1100332 17349652
prefixlister -speed-mode AS-SET-LONAP-CONNECTED 2.26s user 0.24s system 27% cpu 9.005 total
sort -u 5.44s user 0.08s system 51% cpu 10.674 total
wc 0.46s user 0.02s system 4% cpu 10.672 total
10.672s... Well, SHUT UP IT'S THE THOUGHT THAT COUNTS! =)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment