Skip to content

Instantly share code, notes, and snippets.

View trevnorris's full-sized avatar

Trevor Norris trevnorris

View GitHub Profile
'use strict';
const ITER = 1e7;
function Foo() {
this.futz = this.constructor.futz;
}
Foo.futz = false;
@trevnorris
trevnorris / binding.gyp
Last active August 29, 2015 14:20
Compiles against io.js v2.0
{
"targets": [{
"target_name": "addon",
"sources": [ "main.cc" ]
}]
}
@trevnorris
trevnorris / try-catch-finally-stuff.js
Created May 13, 2015 17:10
Observe the performance difference between finally and catch
'use strict';
const ITER = 1e7;
function parseArgs(args, start) {
var arr = [];
for (var i = start; i < args.length; i++)
arr.push(args[i]);
return arr;
#include <v8.h>
#include <node.h>
using namespace v8;
class Visitor42 : public PersistentHandleVisitor {
public:
virtual void VisitPersistentHandle(Persistent<Value>* value,
uint16_t class_id) {
if (class_id == 0xA10C)
'use strict';
function spliceOne(array, index) {
var newLength = array.length - 1;
for (var i = index; i < newLength; ++i) {
array[i] = array[i + 1];
}
array.length = newLength;
}

Here is the output from running with all IRHydra flags.

(gdb) r
Starting program: /var/projects/nubjs-deps/v8/out/x64.debug/d8 /tmp/crash.js
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
#
# Fatal error in CALL_AND_RETRY_LAST
# Allocation failed - process out of memory
#
'use strict';
const net = require('net');
const log = process._rawDebug;
function pServer(port) {
return new Promise(function(res, rej) {
let serv = net.createServer().listen(port, function() {
How to build/use
- Put these in the same folder then run
$ /path/to/nsolid/nsolid $(which node-gyp) rebuild --nodedir=/path/to/nsolid/../
If it builds properly then run
$ /path/to/nsolid/nsolid run.js
'use strict';
const SlowBuffer = require('buffer').SlowBuffer;
const ITER = 1e7;
const SIZE = 65536;
let t = process.hrtime()
for (let i = 0; i < ITER; i++) {
new SlowBuffer(SIZE);
}