underscore vs plain

Benchmark created by Fake on


Preparation HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"></script>

Setup

function compareCaseInsensitive(a, b) {
               return (a && a.toUpperCase()) === (b && b.toUpperCase());
             }
    
    var code = 'abc2'

Test runner

Ready to run.

Testing in
TestOps/sec
NO US
var inputCodes = 'abc1,abc2,abc3'.toUpperCase().replace(/ /g, '').split(','); 
var rest = _.reject(inputCodes, function (iCode) { 
    return iCode === code; 
}); 
rest.join(','); 
ready
US
var inputCodes = _.map('abc1,abc2,abc3'.split(','), $.trim);
var rest = _.reject(inputCodes, _.partial(compareCaseInsensitive, code));
rest.join(',');
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.

  • Revision 1: published by Fake on