Last active
March 28, 2023 08:43
-
-
Save JobLeonard/1ee4ba07024a76ddfbc1bb2a8ecb2f0a to your computer and use it in GitHub Desktop.
Bit Array fill test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"title":"Bit Array fill test","initialization":"class BitArrayU8 {\n constructor(length) {\n this.bits = new Uint8Array(Math.ceil(length / 8));\n this.length = length;\n }\n\n fill(bool) {\n this.bits.fill(bool ? 255 : 0);\n }\n}\n\nclass BitArrayU32 {\n constructor(length) {\n this.bits32 = new Uint32Array(Math.ceil(length / 32));\n this.bits = new Uint8Array(this.bits32.buffer);\n this.length = length;\n }\n\n fill(bool) {\n this.bits32.fill(bool ? 0xFFFFFFFF : 0);\n }\n}\n\nclass BitArrayBI64 {\n constructor(length) {\n this.bits64 = new BigInt64Array(Math.ceil(length / 64));\n this.bits = new Uint8Array(this.bits64.buffer);\n this.length = length;\n }\n\n fill(bool) {\n this.bits64.fill(bool ? 0xFFFFFFFFFFFFFFFFn : 0);\n }\n}","setup":"// runs before each test\nconst bitArrU8 = new BitArrayU8(1000000);\nconst bitArrU32 = new BitArrayU32(1000000);\nconst bitArrBI64 = new BitArrayBI64(1000000);","tests":[{"name":"Bit Array with U8 fill","code":"bitArrU8.fill(true);","results":{"aborted":false,"count":976,"cycles":2,"hz":7659.791932834456,"stats":{"moe":0.00000392371694435468,"rme":3.0054855397093836,"sem":0.000002001896400180959,"deviation":0.000013127312576208115,"mean":0.00013055184902783078,"variance":1.7232633547347174e-10,"numSamples":43},"times":{"cycle":0.12741860465116284,"elapsed":6.006,"period":0.00013055184902783078,"timeStamp":1679992959311}},"platforms":{"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0":{"aborted":false,"count":976,"cycles":2,"hz":7659.791932834456,"stats":{"moe":0.00000392371694435468,"rme":3.0054855397093836,"sem":0.000002001896400180959,"deviation":0.000013127312576208115,"mean":0.00013055184902783078,"variance":1.7232633547347174e-10,"numSamples":43},"times":{"cycle":0.12741860465116284,"elapsed":6.006,"period":0.00013055184902783078,"timeStamp":1679992959311}},"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36":{"aborted":false,"count":36600,"cycles":3,"hz":451080.77360637067,"stats":{"moe":1.3535306667263317e-8,"rme":0.6105516602468604,"sem":6.9057687077874065e-9,"deviation":5.567608727231668e-8,"mean":0.0000022168978562421195,"variance":3.099826693954623e-15,"numSamples":65},"times":{"cycle":0.08113846153846158,"elapsed":6.082,"period":0.0000022168978562421195,"timeStamp":1679992903479}}}},{"name":"Bit Array with U32 fill","code":"bitArrU32.fill(true);","results":{"aborted":false,"count":2274,"cycles":4,"hz":29638.659211701,"stats":{"moe":2.1789974261898346e-7,"rme":0.6458256213801411,"sem":1.1117333807090993e-7,"deviation":9.031764680596494e-7,"mean":0.00003373971787513288,"variance":8.157277324567028e-13,"numSamples":66},"times":{"cycle":0.07672411844805216,"elapsed":6.032,"period":0.00003373971787513288,"timeStamp":1679992965326}},"platforms":{"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0":{"aborted":false,"count":2274,"cycles":4,"hz":29638.659211701,"stats":{"moe":2.1789974261898346e-7,"rme":0.6458256213801411,"sem":1.1117333807090993e-7,"deviation":9.031764680596494e-7,"mean":0.00003373971787513288,"variance":8.157277324567028e-13,"numSamples":66},"times":{"cycle":0.07672411844805216,"elapsed":6.032,"period":0.00003373971787513288,"timeStamp":1679992965326}},"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36":{"aborted":false,"count":36600,"cycles":3,"hz":450653.5328660735,"stats":{"moe":1.6913921822321945e-8,"rme":0.762231862384996,"sem":8.629551950164259e-9,"deviation":6.957367207455665e-8,"mean":0.0000022189995796553156,"variance":4.8404958459379434e-15,"numSamples":65},"times":{"cycle":0.08121538461538455,"elapsed":5.994,"period":0.0000022189995796553156,"timeStamp":1679992909572}}}},{"name":"Bit Array with BigInt64 fill","code":"bitArrBI64.fill(true);","results":{"aborted":false,"count":2609,"cycles":4,"hz":33809.11925711899,"stats":{"moe":1.9738131611655358e-7,"rme":0.6673288455711663,"sem":1.007047531206906e-7,"deviation":8.243039300971757e-7,"mean":0.000029577818706100596,"variance":6.794769691736496e-13,"numSamples":67},"times":{"cycle":0.07716852900421646,"elapsed":6.118,"period":0.000029577818706100596,"timeStamp":1679992971364}},"platforms":{"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36":{"aborted":false,"count":34580,"cycles":5,"hz":452803.01809846505,"stats":{"moe":1.1921714243852637e-8,"rme":0.5398188190523934,"sem":6.0825072672717536e-9,"deviation":5.015763986309694e-8,"mean":0.0000022084658450367115,"variance":2.5157888366361315e-15,"numSamples":68},"times":{"cycle":0.07636874892136948,"elapsed":6.39,"period":0.0000022084658450367115,"timeStamp":1679992915572}},"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0":{"aborted":false,"count":2609,"cycles":4,"hz":33809.11925711899,"stats":{"moe":1.9738131611655358e-7,"rme":0.6673288455711663,"sem":1.007047531206906e-7,"deviation":8.243039300971757e-7,"mean":0.000029577818706100596,"variance":6.794769691736496e-13,"numSamples":67},"times":{"cycle":0.07716852900421646,"elapsed":6.118,"period":0.000029577818706100596,"timeStamp":1679992971364}}}}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment