slugify
JavaScript performance comparison
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.
| Test | Ops/sec | |
|---|---|---|
Underscore String |
|
pending… |
String.Slugify.js |
|
pending… |
Underscore String 2 |
|
pending… |
You can edit these tests or add even more tests to this page by appending /edit to the URL.
0 comments