GUID / UUID in Javascript (v2)

Revision 2 of this benchmark created by Fábio C. Barrionuevo da Luz on


Preparation HTML

<script>
function guidGenerator() {
    var S4 = function() {
       return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
    };
    return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}
function guidRender() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {var r = Math.random()*16|0,v=c=='x'?r:r&0x3|0x8;return v.toString(16);});
}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Jeff Ward-uuid4
UUID.generate();
ready
Brian Haak-uuid4
uuid();
ready

Revisions

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

  • Revision 1: published by kelvin on
  • Revision 2: published by Fábio C. Barrionuevo da Luz on