Skip to content

Instantly share code, notes, and snippets.

@tricknotes
tricknotes / benchmark.js
Created Dec 10, 2012
Performance check about arguments
View benchmark.js
var now;
var fn, i;
var count = 10000000;
now = Date.now();
fn = function() {
arguments[0];
}
for (i = 0; i < count; i++) {
fn();
@tricknotes
tricknotes / app.js
Created Dec 9, 2010
Sapporo.js-2010.11.27のデモアプリ
View app.js
var sys = require("sys");
var express = require("express");
// see http://github.com/redsquirrel/simple_pusher
var simple_pusher = require(__dirname + "/lib/simple_pusher");
var GraphData = require(__dirname + "/qa_data").GraphData;
var graphData = new GraphData(["yes", "little", "no"]);
@tricknotes
tricknotes / 0_reuse_code.js
Created Jan 20, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View ember-demo.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://builds.emberjs.com/handlebars-1.0.0.js"></script>
<script src="http://builds.emberjs.com/tags/v1.0.0/ember.js"></script>
</head>
<script type="text/x-handlebars">
View Gemfile
source 'https://rubygems.org'
gem 'activerecord', '4.0.0.beta1', require: 'active_record'
gem 'enumerize', github: 'brainspec/enumerize'
gem 'sqlite3'
View benchmark.js
var https = require('https');
var tls = require('tls');
var i, now, count = 10000000;
var port = 10443, host = 'localhost', options = {};
var agent = new https.Agent();
// stub function
tls.connect = function() {};
now = Date.now();
View benchmark.js
var Readable = require('stream').Readable;
var i, now, count = 1000000;
var source = Readable.toString().split('\n')[9];
now = Date.now();
for (i = 0; i < count; i++) {
new Readable();
}
View benchmark.js
var domain = require('domain');
var i, now, count = 10000000;
var source = domain.Domain.toString();
now = Date.now();
for (i = 0; i < count; i++) {
domain.create();
}
@tricknotes
tricknotes / benchmark.js
Created Dec 10, 2012
Performance check about arguments with EventEmitter
View benchmark.js
var EventEmitter = require('events').EventEmitter
var i;
var count = 100000000;
var e = new EventEmitter();
e.on('hi', function() {});
now = Date.now();
for (i = 0; i < count; i++) {
e.emit('hi');
@tricknotes
tricknotes / bench.js
Created Dec 8, 2012
Performance check about deleting property null assignment
View bench.js
var now;
var obj, i;
var count = 10000000;
var key = 'key';
obj = {};
now = Date.now();
for (i = 0; i < count; i++) {
obj[key] = 1;
obj[key] = null;