-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
faster/slower math #66
Comments
EDIT: This comment is moved to separate issue #68 Can confirm, something seems to be off. In my case (https://jsbench.me/3pkjlwzhbr/1), it says that |
@e6voe9 let's first take a look at your report. From my first glance, I don't see a problem. Point is that we calculate slower percent and not faster percent. We cannot calculate faster percent because there can be more than 1 alternative case, so question would be "faster than what?". When we calculate slower percent, then it is always compared to fastest case, which is only one. Code that does this is: So, in your case, fastest case can make 666M ops per second. Slower case can do 3.7M ops per second, which means that in any given second, slower case will do only 3.7 ops out of max possible 666 ops, which is 3.7/666 = 5.6% work of the fastest case. Yes, I could also output "5.6% of the max", but IMHO, it's exactly the same as "94.40% slower than max". What you're suggesting is 666/3.7 = 18000%, but the meaning of that is "faster case is 18000% faster than slower case" which is also correct, but for reasons stated above - not very useful when having more than 2 cases. So, in my opinion only real question here is how to represent results: Some other JS benchmarks use option 2, which is easily visualized with a bar chart. I could also think of some hybrid of the above, or move this to settings. But personally, I prefer option 1 as it is. So far, I never got a complaint on this. Would like to know how others feel. EDIT: difference in calculation.... from 99,45% slower displayed currently to 94,40% slower that I calculated manually is probably due to variance and also rounding (which takes a lot when difference in ops/s is large). This difference should not be nearly as large on cases with similar speeds (where this actually matters) |
@psiho Thank you for this instruction. I feel like option 3 is closer to my mind. Documentation on the webpage will be definitely helpful, so everybody can easy understand that 94% slower means "6% of the fastest case speed". |
Tested
.match()
vs.includes()
to define which is faster. Of course.includes()
is faster, I wanted to know how big the difference.Results are:
.match()
- 3.7M operations/second.includes()
- 666M operations/secondSomehow it says that
.match()
is 99.45% slower. How?It's clear that the difference is ~18000%
Including data to test yourself:
Setup JavaScript
case 1
case 2
Attaching screenshot as well
![image](https://private-user-images.githubusercontent.com/54411613/238429920-551495bd-1597-421d-93b3-a12f9eff492f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwMTM0MTQsIm5iZiI6MTczOTAxMzExNCwicGF0aCI6Ii81NDQxMTYxMy8yMzg0Mjk5MjAtNTUxNDk1YmQtMTU5Ny00MjFkLTkzYjMtYTEyZjllZmY0OTJmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDExMTE1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBjZWJiZTc3YjNhZGQ1Y2ZmMjhkNmRjZWQ5ZWI1MjdjZjFiNmNiNGJlZmQ2YzgzOGFmMjNjZGJlN2U1YmU4MzUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Y20Kk7FQfnrzqj3HC8MPqiVZ04VENdXTn9EyeKxJtWc)
The text was updated successfully, but these errors were encountered: