Skip to content

Instantly share code, notes, and snippets.

Avatar

Rob Palmer robpalme

  • Bloomberg L.P.
  • London
View GitHub Profile
@robpalme
robpalme / tsc-optimized.js
Last active Jul 2, 2020
Property-to-Var optimisation on TypeScript Compiler
View tsc-optimized.js
var ts_versionMajorMinor,
ts_version,
ts_tryGetNativeMap,
ts_Map,
ts_createMapShim,
ts_emptyArray,
ts_createMap,
ts_createMapFromEntries,
ts_createMapFromTemplate,
ts_length,
View Typescript.md
@robpalme
robpalme / function-constructor-base-cost.js
Created Oct 17, 2018
Compare calling Function() once-per-function vs first concatenating source text into an array of functions
View function-constructor-base-cost.js
{
function empty () {}
const fnsLength = 10;
const fns = new Array(fnsLength).fill(empty);
const fnStrings = fns.map(x => x.toString());
var ix = 0;
@robpalme
robpalme / bench-james-both.js
Created Sep 7, 2017
Creation & call times for different binding techniques
View bench-james-both.js
// Micro-benchmark to answer the question in https://twitter.com/thejameskyle/status/905403367949647874
if (typeof console === 'undefined') console = {log:print};
var closuresOriginal = (function() {
const outer = a => {
const inner = b => a + b;
return inner(2);
};
View bench-james.js
// Micro-benchmark to answer the question in https://twitter.com/thejameskyle/status/905403367949647874
if (typeof console === 'undefined') console = {log:print};
var closuresOriginal = (function() {
const outer = a => {
const inner = b => a + b;
return inner(2);
};
@robpalme
robpalme / linear-search.js
Last active Aug 22, 2017
Linear string search perf
View linear-search.js
(function() {
const Y_IX = 1e6;
const str = "x".repeat(Y_IX) + "y";
function regexp (str) {
return /y/.exec(str).index;
}
@robpalme
robpalme / defineProperty.js
Created Aug 15, 2017
defineProperty vs standard property assignment
View defineProperty.js
const TEST_LOOP_COUNT = 1e5;
const VAL = "woo";
const DESC = { value: VAL, configurable: true, enumerable: true, writable: true };
const propNames = [ "i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8", "i9" ];
const PROP_COUNT = propNames.length;
function literal () {
return {
[propNames[0]]: VAL,
@robpalme
robpalme / bench-sam.js
Last active Aug 13, 2017 — forked from bmeurer/bench-sam.js
Add aafeApplyFunctionsRest
View bench-sam.js
function applyFunctionsRest(functions, ...args) {
for (var i = 0, l = functions.length; i < l; ++i) {
functions[i].apply(this, args);
}
}
var safeApply = Function.prototype.call.bind(Function.prototype.apply);
function safeApplyFunctionsRest(functions, ...args) {
for (var i = 0, l = functions.length; i < l; ++i) {
You can’t perform that action at this time.