Coder Social home page Coder Social logo

Comments (6)

kms0219kms avatar kms0219kms commented on August 14, 2024 1

@sossost , 사실 랜덤은 보통 양수에서 많이 발생하고 음수에서는 잘 일어나지 않습니다. Math.random()도 음수를 지원하진 않아서, 야매로 작업해야 합니다.

이 라이브러리는 속도와 안정성 두가지 모두 중요시 하는 라이브러리이기 때문에, 이 방식으로의 전환은 조금 조심해야 한다는 부분에서는 동의합니다만, 본 이슈를 통해 본 라이브러리가 중요시 하는 부분 등을 전체적으로 확인할 수 있는 계기가 되면 좋겠습니다.

In fact, randomness usually occurs a lot in positive numbers and rarely occurs in negative numbers. Math.random() also does not support negative numbers, so you have to work with it manually.

Since this library is one that values ​​both speed and stability, I agree that you need to be a little cautious when switching to this method, but I hope that this issue will serve as an opportunity to check the important aspects of this library as a whole.

from es-toolkit.

sossost avatar sossost commented on August 14, 2024 1

@kms0219kms However, the random function supports negative ranges and will generate random numbers in the range above minimum (inclusive) and below maximum (exclusive).
So for consistency in implementation, math.floor seems to be better suited for the simplicity case.
It seems like a good case to think about the performance benefits �and simplicity of implementation.

from es-toolkit.

raon0211 avatar raon0211 commented on August 14, 2024 1

In my opinion, we should consider using bitwise operators only if there's a significant performance improvement.

However, based on the information provided by @kms0219kms (link), the performance difference doesn't seem substantial enough to justify the loss of readability.

For now, I suggest we prioritize simplicity in our implementation.

from es-toolkit.

kms0219kms avatar kms0219kms commented on August 14, 2024
Screenshot 2024-06-16 at 5 53 37 PM

벤치마크는 https://jsperf.app/pugihi 에서 확인 가능합니다.

from es-toolkit.

sossost avatar sossost commented on August 14, 2024

Sorry I deleted and rewrote the comment.

Personally, I think Math.floor is better suited to the principles of implementation simplicity that this library stands for in terms of consistency and readability, unless the performance benefits are significant enough.
Also, the double tilde operator behaves differently for positive and negative numbers.
What do you think?

from es-toolkit.

kms0219kms avatar kms0219kms commented on August 14, 2024

In my opinion, we should consider using bitwise operators only if there's a significant performance improvement.

However, based on the information provided by @kms0219kms (link), the performance difference doesn't seem substantial enough to justify the loss of readability.

For now, I suggest we prioritize simplicity in our implementation.

네, 현재 비트연산으로의 floor처리는 일반적인 PC환경에서는 성능차이가 존재하나 유의미한 정도로 크진 않습니다.

모바일에서는 3~5% 정도 속도가 빠른 유의미한 결과가 나오긴합니다만, 가독성과 안정성 손실을 정당화할 만큼 유의미하진 않다는 의견에는 동의합니다.

앞으로 나아갈 방향이 이미 명확하게 결정된 것으로 보이므로 이슈를 마무리하겠습니다.

Yes, there is a performance difference in the floor using current bit operations in a general PC, but it is insignificant.

On mobile, there are meaningful results about 3-5% faster, but I agree that it is not significant enough to justify the loss of readability and stability.

I would close this issue as the pathway forward has already been clearly decided.

from es-toolkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.