What's the most efficient way to turn an object's keys to its lowercase version
JavaScript performance comparison
Info
http://stackoverflow.com/questions/12539574/whats-the-best-way-most-efficient-to-turn-all-the-keys-of-an-object-to-lower
Preparation code
<script>
Benchmark.prototype.setup = function() {
var obj = {
"SomeThing" : 2,
"OthErThing" : 9,
"AnotherThing" : 10000,
"OhAndOneMoreThing" : 193013923,
"aQuiteLargeStringaQuiteLargeStringaQuiteLargeString" : 29320381,
"SomeThing2" : 2,
"OthErThing2" : 9,
"AnotherThing2" : 10000,
"OhAndOneMoreThing2" : 193013923,
"aQuiteLargeStringaQuiteLargeStringaQuiteLargeString2" : 29320381,
"SomeThing3" : 2,
"OthErThing3" : 9,
"AnotherThing3" : 10000,
"OhAndOneMoreThing3" : 193013923,
"aQuiteLargeStringaQuiteLargeStringaQuiteLargeString3" : 29320381,
"SomeThing4" : 2,
"OthErThing4" : 9,
"AnotherThing4" : 10000,
"OhAndOneMoreThing4" : 193013923,
"aQuiteLargeStringaQuiteLargeStringaQuiteLargeString4" : 29320381,
"SomeThing5" : 2,
"OthErThing5" : 9,
"AnotherThing5" : 10000,
"OhAndOneMoreThing5" : 193013923,
"aQuiteLargeStringaQuiteLargeStringaQuiteLargeString5" : 29320381
}
};
</script>
Test runner
Warning! For accurate results, please disable Firebug before running the tests. (Why?)
Java applet disabled.
| Test | Ops/sec | |
|---|---|---|
joaojeronimo's function |
|
pending… |
Don't check if the key is already in lower case |
|
pending… |
Compare results of other browsers
Revisions
You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:
- Revision 1: published by João Jerónimo
- Revision 1: published by João Jerónimo
- Revision 1: published by João Jerónimo
- Revision 2: published
- Revision 3: published
0 comments