This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var buffalo = require("../buffalo"); | |
function test(obj, iter, fn, name) { | |
var then = new Date().getTime(); | |
var p; | |
var runs = 0; | |
while(iter--) { | |
p = fn(obj); | |
runs++ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lineParser = function(_command) { | |
var _parser = this; | |
if(!_command) _command = new Buffer(1024); | |
var _loc = 0; | |
_parser.execute = function(buffer, start, len) { | |
var end = start + len; | |
if(start > end) { | |
if(_parser.onError) _parser.onError(new Error("out of range")); | |
return -1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handleFailure(err) { | |
next(new DbError(err)); | |
} | |
function findBlog(blog) { | |
function setUsers() { | |
// do stuff | |
} | |
function setBlog() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handleFailure(err) { | |
next(new DbError(err)); | |
} | |
function findBlogCb(blog) { | |
var proj; | |
function setBlogCb() { | |
proj.setUsers(users).on("success", setUsersCb).on("failure", handleFailure); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Adder(cb) { | |
var _adder = this; | |
var _complete = false; | |
var _result = 0; | |
var _jobs = 0; | |
_adder.add = function(x,y) { | |
setTimeout(function() { | |
_result += (x+y); | |
_jobs--; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
#define ITEMS 1<<24 | |
#define ITER 10 * 1024 * 1024; | |
static int A1[ITEMS]; | |
static int A2[ITEMS]; | |
static int A3[ITEMS]; | |
static int A4[ITEMS]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
/* | |
This program tests the performance characteristics of write combining | |
On an intel CPU only 4 writes at a time will be combined so we should see | |
a big performance improvement if we only write to distinct memory locations | |
<=4 times per iteration of a loop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
#include <sys/time.h> | |
#define P 2 | |
static uint64_t volatile counter = 0; | |
pthread_mutex_t mutex; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cluster = require('cluster'); | |
function fib (n) { | |
if (n < 2) { | |
return 1; | |
} | |
else { | |
return fib(n-2) + fib(n-1); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Buffer.prototype.xwriteUInt8 = function(value, offset) { | |
this[offset] = value & 0xff; | |
} | |
Buffer.prototype.xwriteUInt16BE = function(value, offset) { | |
this[offset++] = (value >>> 8) & 0xff; | |
this[offset] = value & 0xff; | |
} | |
Buffer.prototype.xwriteUInt32BE = function(value, offset) { |