Skip to content

Instantly share code, notes, and snippets.

@canalun
Created February 26, 2024 05:18
Show Gist options
  • Save canalun/12f7d9226d13c431682371f723feccc7 to your computer and use it in GitHub Desktop.
Save canalun/12f7d9226d13c431682371f723feccc7 to your computer and use it in GitHub Desktop.
// after runnig this code on the console, click click click as fast as possible.
let a = null
let results = []
window.addEventListener('click', (e) => {
if (a === null){
a = performance.now()
return
}
const b = performance.now()
const result = b-a;
results.push(result)
const ave = results.reduce((prev,acc)=>{return prev+acc},0) / results.length
const v = Math.sqrt(results.reduce((prev,acc)=>{return prev+(acc-ave)*(acc-ave)},0)/results.length)
console.log(
ave,
v
)
a = b
})
@canalun
Copy link
Author

canalun commented Feb 26, 2024

result on 2024/2/20
121.31562500447035 11.141619882320713

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment