Joined August 2016
·

leif_eriksen

Automation Engineer at Sportsbet
·
Melbourne, Australia
·
·

For comparison with Node 6.8.1, I wrote a benchmark for the following techniques (in coffeescript)

Benchmark = require 'benchmark'
assert = require 'assert'

suite = new Benchmark.Suite

convert = "1234"
suite.add 'parseInt', ->
    assert(parseInt(convert, 10) is 1234)
.add 'Number(x)', ->
    assert(Number(convert) is 1234)
.add '~~convert', ->
    assert((~~convert) is 1234)
.add 'convert|0', ->
    assert((convert|0) is 1234)
.add '+convert', ->
    assert((+convert) is 1234)
.on 'complete', ->
    @map (b) ->
        console.log(" b.hz #{b.hz} b.name #{b.name}")
    console.log('Fastest is ' + @filter('fastest').map('name'))
.run
    async : true

Result
~~~
.nvm/versions/node/v6.8.1/bin/node --require coffee-script/register src/liveserv-loader/test/benchmark.coffee
b.hz 62781513.35543358 b.name parseInt
b.hz 71269790.1318596 b.name Number(x)
b.hz 22889466.345643885 b.name ~~convert
b.hz 24447918.3306923 b.name convert|0
b.hz 78516405.25189222 b.name +convert
Fastest is +convert

Process finished with exit code 0
~~~

Generally +<string> is fastest, but Number() occassionally comes out on top too.

if you have a grunt task setup to run mocha (or whatever) , its even easier

istanbul cover --report html grunt test

Using an SCM (be it GIT, svn, hg or whatever) is an excellent means of distributing all kinds of assets - images, control files, scripts. I even know people who keep their .bashrc and .profile files (and other portable tools) in github and pull them down as they move to different client sites. The efficiency that comes with versioning, hosting and accessing through these tools can make you look super-organised

Achievements
1 Karma
0 Total ProTip Views