Skip to content

Instantly share code, notes, and snippets.

Trevor Norris trevnorris

Block or report user

Report or block trevnorris

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@trevnorris
trevnorris / prime-generator.js
Last active Jan 12, 2016
fastest js prime generator been able to get
View prime-generator.js
// Thanks to @isntitvacant (https://github.com/chrisdickinson) for optimizing the
// bit shift performance tweaks.
var SB = require('buffer').SlowBuffer;
var ITER = 2e4;
var SIZE = 1e3;
function genPrimes(max) {
var primes = new Array();
var len = (max >>> 3) + 1;
View cp-fork.sh
#!/bin/bash
trap "exit" SIGINT SIGQUIT
make -j4
echo
echo -n "running ."
while :; do
for i in `seq 50`; do
./node test/simple/test-child-process-fork-getconnections.js 2> ./cp-out.log
View allocate-persist.cc
Handle<Value> QuickCallback(const Arguments& args) {
HandleScope scope(node_isolate);
size_t length = args[0]->Uint32Value();
Local<Object> obj = args[1]->ToObject();
Local<Function> fn = args[2].As<Function>();
char* data = new char[length];
obj->SetIndexedPropertiesToExternalArrayData(data,
kExternalUnsignedByteArray,
@trevnorris
trevnorris / test-read-encodings.js
Created Jun 10, 2013
test all the toString() encodings
View test-read-encodings.js
var types = [/* */'ascii', 'utf8', 'hex', 'base64', 'ucs2', 'binary'/* */];
var tests = [[1e6, 16, 256, 512, 1024],
[1e5, 1024 * 8, 1024 * 32, 1024 * 64],
[1e3, 1024 * 128, 1024 * 256, 1024 * 512, 1024 * 1024,
1024 * 1024 * 5]];
var iter;
tests.forEach(function(items) {
items.forEach(function(size, idx) {
@trevnorris
trevnorris / Doxyfile
Created Jun 20, 2013
My doxygen file for v8. Yeah, I know it needs to be cleaned up. :P
View Doxyfile
# Doxyfile 1.8.1.2
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
#
# All text after a hash (#) is considered a comment and will be ignored.
# The format is:
# TAG = value [value, ...]
# For lists items can also be appended using:
# TAG += value [value, ...]
@trevnorris
trevnorris / a_runme.sh
Last active Dec 21, 2015
HTTP request memory leak (don't delete, https://github.com/joyent/node/issues/6129)
View a_runme.sh
# this only dumps data into the TCP server
for i in `seq 100`
do
nc '127.0.0.1' 9090 < test_ping.txt
done
View really-crapy-multi-write.js
// Something horrible happens and this maxes out at ~800 req/sec.
var TCP = process.binding('tcp_wrap').TCP;
var SlowBuffer = require('buffer').SlowBuffer;
var util = require('util');
var cntr = 0;
var err;
var headers = 'HTTP/1.1 200 OK\r\n' +
'Server: TCPTest\r\n' +
@trevnorris
trevnorris / async-listener-api.js
Last active Dec 21, 2015
Possible asyncListener API for Node.
View async-listener-api.js
// Class that will store information about a specific request.
function Domain() { }
// This will be called every time asynchronous work is queued.
// The returned data will propagate to the callbackObject's callbacks.
// If no callbackObject is passed to asyncListener then the return value
// will be discarded.
// The context (i.e. "this") of the calling method will be passed as the
// first argument.
function onAsync(context) {
View uv-common-disas.asm
Dump of assembler code for function uv__getaddrinfo_translate_error:
0x00000000009828b0 <+0>: push %rbp
0x00000000009828b1 <+1>: mov %rsp,%rbp
0x00000000009828b4 <+4>: sub $0x20,%rsp
0x00000000009828b8 <+8>: mov %edi,-0x8(%rbp)
0x00000000009828bb <+11>: mov %edi,%eax
0x00000000009828bd <+13>: sub $0xfffffff4,%edi
0x00000000009828c0 <+16>: mov %eax,-0xc(%rbp)
0x00000000009828c3 <+19>: mov %edi,-0x10(%rbp)
0x00000000009828c6 <+22>: ja 0x9828e1 <uv__getaddrinfo_translate_error+49>
View gist:6525326
Ticks per symbol:
164979 60.0% LazyCompile:*EventEmitter.removeListener events.js:200 [js]
22855 8.3% Stub:CompareICStub [js]
1940 0.7% v8::internal::JSObject::SetPropertyForResult(...
Stats:
275340 total trace events
275095 total ticks
16910 ticks not in symbols
13184 4.8% ticks in unaccounted ticks (probably in the kernel, try --kernel)
You can’t perform that action at this time.