Skip to content

Instantly share code, notes, and snippets.

View mcollina's full-sized avatar

Matteo Collina mcollina

View GitHub Profile
test('Register an hook after a plugin', t => {
t.plan(6)
const fastify = Fastify()
fastify.register(fp(function (instance, opts, next) {
instance.addHook('preHandler', function (req, reply, next) {
t.ok('called')
next()
})
#! /bin/bash
set -x
set -e
curl -L https://github.com/nodejs/node/pull/$1.patch | git am --whitespace=fix
get-metadata $1 -f msg.txt
echo -e "$(git show -s --format=%B)\n\n$(cat msg.txt)" > msg.txt
git commit --amend -F msg.txt
git show -s --format=%B
var querystring = require('querystring')
function createManyParams (count) {
var str = ''
if (count === 0) {
return str
}
$ ./deps/v8/tools/mac-tick-processor isolate-0x102801600-v8.log
Statistical profiling result from isolate-0x102801600-v8.log, (5977 ticks, 162 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
3 0.1% /usr/lib/system/libsystem_pthread.dylib
1 0.0% /usr/lib/system/libdyld.dylib
[JavaScript]:
ticks total nonlib name
var max = 100000000
console.time('empty loop')
function loop () {
for (var i = 0; i < max; i++) {}
}
loop()
'use strict'
var benchmark = require('benchmark')
var suite = new benchmark.Suite()
var runs = 0
class MyClass {
constructor (x) {
this.x = x
}
'use strict'
var benchmark = require('benchmark')
var suite = new benchmark.Suite()
var runs = 0
class MyClass {
constructor (x) {
this.x = x
}
@mcollina
mcollina / object-creation.js
Created July 28, 2017 22:45
bench-object-creation
'use strict'
var benchmark = require('benchmark')
var suite = new benchmark.Suite()
var runs = 0
class MyClass {
constructor (x) {
this.x = x
}
@mcollina
mcollina / bug.js
Created July 6, 2017 12:22
endless deopt-opt cycle
'use strict'
var MAX = 1000000000
var factory = {
create() {
throw new Error('kaboom')
return {
something() {
return 'hello world'
}
@mcollina
mcollina / benchmark.js
Created June 7, 2017 17:16
pino-multistream-benchmark
'use strict'
var bench = require('fastbench')
var bunyan = require('bunyan')
var pinoms = require('./index')
var fs = require('fs')
var dest = fs.createWriteStream('/dev/null')
var pino = require('pino')
var tenStreams = [