slugify

JavaScript performance comparison

Test case created

Preparation code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

<script src="http://underscorejs.org/underscore-min.js"></script>

<script src="https://raw.github.com/epeli/underscore.string/master/lib/underscore.string.js"></script>

<script src="//ajax.googleapis.com/ajax/libs/mootools/1.3/mootools-yui-compressed.js"></script>

<script src="http://fiddle.jshell.net/js/lib/mootools-more-1.3rc1-nocompat-yc-js"></script>



<script src="https://raw.github.com/stipsan/String.Slugify.js/master/Source/String.Slugify.js"></script>
<script>
Benchmark.prototype.setup = function() {
    var text = "slugify  ME    now MotherFucker";
   
   
    _.string.slugify2 = function(str) {
          if (str == null) return '';
          str = String(str).toLowerCase();
          return _.string.dasherize(str.replace(/[^\w\s-]/g, ''));
    };
};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
Underscore String
_.string.slugify(text);
pending…
String.Slugify.js
text.slugify()
pending…
Underscore String 2
_.string.slugify2(text);
pending…

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

Compare results of other browsers

0 comments

Add a comment