Skip to content

Instantly share code, notes, and snippets.

@JobLeonard
Created February 26, 2024 14:58
Show Gist options
  • Save JobLeonard/23cbeda28c7ee384aae961a061e02233 to your computer and use it in GitHub Desktop.
Save JobLeonard/23cbeda28c7ee384aae961a061e02233 to your computer and use it in GitHub Desktop.
new Cell vs createCell, assign to global
{"title":"new Cell vs createCell, assign to global","initialization":"class Cell {\n constructor(fcsFiles) {\n this.fcsFiles = fcsFiles;\n this.fcsFile = fcsFiles.length === 1 ? fcsFiles[0] : null;\n this.fcsFileId = this.fcsFile?._id ?? null;\n }\n}\n\nfunction createCell(fcsFiles) {\n return {\n fcsFiles,\n fcsFile: fcsFiles.length === 1 ? fcsFiles[0] : null,\n fcsFileId: fcsFiles[0]?._id ?? null\n };\n}\n\nlet t = null","setup":"// runs before each test\n","tests":[{"name":"new Cell(fcsFiles)","code":"t = new Cell([]);\nt = new Cell([{_id: 1}]);\nt = new Cell([{_id: 1}, {_id: 2}]);","results":{"aborted":false,"count":892401,"cycles":6,"hz":11383320.378912939,"stats":{"moe":9.067734024998875e-10,"rme":1.0322092151733193,"sem":4.6263949107137117e-10,"deviation":3.758500992965055e-9,"mean":8.784783057256762e-8,"variance":1.4126329714119303e-17,"numSamples":66},"times":{"cycle":0.07839549185078991,"elapsed":6.065,"period":8.784783057256762e-8,"timeStamp":1708959535557}},"platforms":{"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36":{"aborted":false,"count":1865861,"cycles":6,"hz":23596165.46134911,"stats":{"moe":9.447351502989634e-10,"rme":2.2292126923606865,"sem":4.820077297443691e-10,"deviation":3.9454033067270185e-9,"mean":4.2379767239639664e-8,"variance":1.5566207252732494e-17,"numSamples":67},"times":{"cycle":0.0790747548815213,"elapsed":6.109,"period":4.2379767239639664e-8,"timeStamp":1708959497652}},"Mozilla/5.0 (X11; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0":{"aborted":false,"count":892401,"cycles":6,"hz":11383320.378912939,"stats":{"moe":9.067734024998875e-10,"rme":1.0322092151733193,"sem":4.6263949107137117e-10,"deviation":3.758500992965055e-9,"mean":8.784783057256762e-8,"variance":1.4126329714119303e-17,"numSamples":66},"times":{"cycle":0.07839549185078991,"elapsed":6.065,"period":8.784783057256762e-8,"timeStamp":1708959535557}}}},{"name":"createCell(fcsFiles)","code":"t = createCell([]);\nt = createCell([{_id: 1}]);\nt = createCell([{_id: 1}, {_id: 2}]);","results":{"aborted":false,"count":1108444,"cycles":6,"hz":13849449.772688761,"stats":{"moe":8.241069396310918e-10,"rme":1.1413427667745055,"sem":4.2046272430157745e-10,"deviation":3.3898788568711093e-9,"mean":7.220503459798156e-8,"variance":1.1491278664261778e-17,"numSamples":65},"times":{"cycle":0.08003523736992507,"elapsed":5.988,"period":7.220503459798156e-8,"timeStamp":1708959541627}},"platforms":{"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36":{"aborted":false,"count":1872510,"cycles":9,"hz":23758322.621270638,"stats":{"moe":8.247052574325518e-10,"rme":1.9593613573540618,"sem":4.207679884859958e-10,"deviation":3.4183352979016514e-9,"mean":4.2090513540914204e-8,"variance":1.1685016208880372e-17,"numSamples":66},"times":{"cycle":0.07881490751049726,"elapsed":6.121,"period":4.2090513540914204e-8,"timeStamp":1708959503767}},"Mozilla/5.0 (X11; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0":{"aborted":false,"count":1108444,"cycles":6,"hz":13849449.772688761,"stats":{"moe":8.241069396310918e-10,"rme":1.1413427667745055,"sem":4.2046272430157745e-10,"deviation":3.3898788568711093e-9,"mean":7.220503459798156e-8,"variance":1.1491278664261778e-17,"numSamples":65},"times":{"cycle":0.08003523736992507,"elapsed":5.988,"period":7.220503459798156e-8,"timeStamp":1708959541627}}}}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment