Reading and Writing Binary Values (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script>
String.prototype.replaceAt = function(index, replacement) {
    return this.substring(0, index) + replacement + this.substring(index + replacement.length);
}
var queryIndex = 7
var binaryLiteral = 0b10000000000000000000000000000000
var binaryString = '10000000000000000000000000000000'
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
Set and Read from String
var updatedBinaryString = binaryString.replaceAt(queryIndex, 1)
var queryUpdatedBinaryString = binaryString.charAt(queryIndex)
ready
Set and Read from Binary
var updatedBinaryLiteral = binaryLiteral ^ (2 ** queryIndex)
var queryUpdatedBinaryLiteral = updatedBinaryLiteral & (2 ** queryIndex)
ready

Revisions

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