---
## linting
> jshint snippets/*.js
snippets/alert.js: line 1, col 17, Missing semicolon.
snippets/console_log.js: line 1, col 19, Missing semicolon.
snippets/console_log.js: line 4, col 26, Missing semicolon.
snippets/console_log.js: line 7, col 25, Missing semicolon.
snippets/console_log.js: line 10, col 35, Missing semicolon.
snippets/console_log.js: line 13, col 21, Missing semicolon.
snippets/console_time.js: line 1, col 20, Missing semicolon.
snippets/console_time.js: line 2, col 10, Missing semicolon.
snippets/console_time.js: line 3, col 23, Missing semicolon.
snippets/console_time.js: line 8, col 21, Missing semicolon.
snippets/console_time.js: line 13, col 34, Missing semicolon.
snippets/console_trace.js: line 1, col 19, Missing semicolon.
snippets/console_trace.js: line 2, col 19, Missing semicolon.
... repeats ad nauseum ...
---
## linting
* jshint -
* jslint -
---
class: center, middle
# etc
---
## builtin module `repl`
```js
//!snippet: repl.js
```
---
## builtin debugger
```js
//!snippet: debugger.js
```
---
## builtin debugger
> node debug debugger.js
< debugger listening on port 5858
connecting... ok
...
debug> watch("x")
debug> cont
break in debugger.js:2
Watchers:
0: x = undefined
1 function a() {
2 debugger
3 var x = 1
4 var y = 2
debug> next
|
...
debug> next
break in debugger.js:4
Watchers:
0: x = 1
2 debugger
3 var x = 1
4 var y = 2
5 console.log(x + " + " ...
6 }
debug> cont
< 1 + 2 = 3
program terminated
debug>
|
---
## npm `hooker`
```js
//!snippet: hooker.js
```
---
## npm `hooker`
prints:
```
-> Math.max: [5,6,7]
<- Math.max: 7
-> Math.sqrt: [2]
<- Math.sqrt: 1.4142135623730951
```
also provides
* filtering arguments
* overriding results
* https://github.com/cowboy/javascript-hooker
---
## node 0.12 module `tracing`
```js
//!snippet: node-12-tracing.js
```
---
## node 0.12 module `tracing`
```js
// prints:
//
// before: [object Timer]
// before: [object Object]
// after: [object Object]
// after: [object Timer]
// before: [object Timer]
// before: [object Object]
// after: [object Object]
// after: [object Timer]
...
```
the bad: spartan!
the good: spartan! lots of low hanging fruit to pick!
---
## node 0.12 module `tracing`
*
* allows userdata to be associated with a handler
* has event emitter `v8` which emits GC information
---
class: center, middle
# tools
---
## node-inspector
* reuses the user interface from Chrome Dev Tools
* set breakpoints
* watch expressions
*
```
sudo npm -g install node-inspector
...
node-debug program.js
```
just for fun, try
```
node-debug `which node-debug`
```
---
---
## IDEs
* Eclipse Orion -
* Eclipse -
* WebStorm -
* Cloud9 IDE -
---
## newrelic
* framework specific timing for:
* express, connect, hapi, restify
* mongodb, redis, mysql, memcached
* add your own:
* unhandled exceptions
* works locally and on a server
---
## newrelic
* get account key from newrelic
* `npm install newrelic`
* `cp node_modules/newrelic/newrelic.js .`
* `edit newrelic.js`, add account key
* add `require('newrelic')` to start of your app
* start app
* watch monitoring dashboard at newrelic
more info:
movie:
---
---
## nodprof
```
nodprof --serve --port 8081&
open http://localhost:8081
...
nodprof `which npm` info grunt
```
sample: http://muellerware.org/nodprof-static/
for more info:
*
*
* other profilers
---
---
class: center, middle
# `fin`