Giter Club home page Giter Club logo

Comments (4)

smallnewer avatar smallnewer commented on June 22, 2024

千万别用forEach循环数组。性能超差。
http://jsperf.com/array-each1
http://jsperf.com/fastest-array-loops-in-javascript/267

from bugs.

smallnewer avatar smallnewer commented on June 22, 2024

常用运算测试:
http://jsperf.com/operation1
http://jsperf.com/operation2

常用运算总体不会特别慢,只是相对间作比较。只在大量运算的时候,可以用性能好的运算方式替换不好的运算方式,可以取得一些优化效果。

  1. 尽量避免 弦操作:sin asin atan 等。
  2. 除法没有乘法性能好,能用乘法尽量用乘法。
  3. 开方性能也不好,和乘法差距较大。不过比弦操作要好不少。
  4. random()获取随机数性能

from bugs.

smallnewer avatar smallnewer commented on June 22, 2024

部分JS性能测试:http://my.oschina.net/u/1401419/blog/191199

from bugs.

smallnewer avatar smallnewer commented on June 22, 2024

判断是否数组。
参照:http://jsperf.com/instanceof-array-vs-array-isarray/5
Array.isArray性能也是糟透。通用的toString方式是最慢的,比isArray慢几个量级。千万别用。
arr instanceof Array 比较靠谱
但是更快的选择是arr.constructor === Array

from bugs.

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.