Skip to content

Instantly share code, notes, and snippets.

@remybach
Created December 20, 2012 12:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save remybach/4345118 to your computer and use it in GitHub Desktop.
A summary of some testing I did on this jsperf test: http://jsperf.com/ordinal-suffix | Blog post about this here: http://remy.bach.me.uk/2012/12/ordinal-suffix
num = '0'
fastest: `< ternary` slowest: `Regex` by 67%.
num = '1'
fastest: `Regex` slowest: `|| ternary` by 65%
num = '2'
fastest: `< ternary` slowest: `|| ternary` by 64%
num = '3'
fastest: `< ternary` slowest: `|| ternary` by 63%
num = '4'
fastest: `Regex` slowest: `|| ternary` by 65%
num = '5'
fastest: `Regex` AND `< ternary` slowest: `|| ternary` by 67%
num = '6'
fastest: `Regex` AND `< ternary` slowest: `|| ternary` by 60%
num = '7'
fastest: `< ternary` slowest: `Regex` by 17%
num = '8'
fastest: `< ternary` slowest: `|| ternary` by 69%
num = '9'
fastest: `Regex` AND `< ternary` slowest: `|| ternary` by 66%
num = '10'
fastest: `Regex` slowest: `|| ternary` by 62%
num = '11'
fastest: `Regex` AND `< ternary` slowest: `|| ternary` by 68%
num = '12'
fastest: `Regex` slowest: `|| ternary` by 68%
num = '13'
fastest: `Regex` slowest: `|| ternary` by 69%
num = '14'
fastest: `Regex` AND `< ternary` slowest: `|| ternary` by 68%
num = '15'
fastest: `Regex` AND `< ternary` slowest: `|| ternary` by 69%
num = '16'
fastest: `Regex` AND `< ternary` slowest: `|| ternary` by 69%
num = '17'
fastest: `Regex` AND `< ternary` slowest: `|| ternary` by 68%
num = '18'
fastest: `Regex` AND `< ternary` slowest: `|| ternary` by 70%
num = '19'
fastest: `Regex` AND `< ternary` slowest: `|| ternary` by 71%
num = '20'
fastest: `|| ternary` slowest: `Slice` by 68%
num = '21'
fastest: `|| ternary` slowest: `Slice` by 75%
num = '22'
fastest: `|| ternary` slowest: `Regex` AND `Slice` by 78%
num = '23'
fastest: `|| ternary` slowest: `Regex` by 83%
num = '24'
fastest: `|| ternary` slowest: `Regex` by 87%
num = '25'
fastest: `< ternary` slowest: `Regex` by 59%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment