Skip to content

Instantly share code, notes, and snippets.

var Benchmark = require('benchmark');
var expect = require('expect');
var suite = new Benchmark.Suite;
var testArray = [1,2,3,4,5,6,7,8,9,10,11,12,13];
var resultat = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26];
suite
.add('forHoley', () => forHoley(testArray))
.add('forPush', () => forPush(testArray))
var Benchmark = require('benchmark');
var expect = require('expect');
var _ = require('lodash');
var R = require('ramda');
var suite = new Benchmark.Suite;
var testArray = [1,2,3,4,5,6,7,8,9,10,11,12,13];
var resultat = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26];
suite
var Benchmark = require('benchmark');
var expect = require('expect');
var _ = require('lodash');
var R = require('ramda');
var suite = new Benchmark.Suite;
var testArray = [
{ items: [{status: 'new', payload: [1, 2, 3]}, {status: 'old'}, {status: 'new', payload: [2, 1, 4]}]},
{ items: [{status: 'new', payload: [8, 2, 7]}, {status: 'new', payload: [0, 2, 9]}, {status: 'old'}]},
{ items: [{status: 'old'}, {status: 'new', payload: [5, 2, 3]}, {status: 'new', payload: [1, 4, 3]}]}
@Tom910
Tom910 / gist:37d3c863103c87741d835738af03b3ba
Created January 13, 2017 08:04
for-cache-vs-no-cache
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
var testArray = [];
for (var s = 0; s < 1000; s++) {
testArray.push(s * 2);
}
suite
@Tom910
Tom910 / Object-keys-vs-for-in.js
Last active January 24, 2017 10:12
Object-keys-vs-for-in
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
var testObject = {};
for (var s = 0; s < 1000; s++) {
testObject[s] = Math.floor(Math.random() * 10000);
}
console.log('Testing iteration of object')
/*
❯ node -v
v14.15.1
❯ node Map-vs-native-cache.js
Testing caching
Map x 57.19 ops/sec ±1.83% (59 runs sampled)
Native x 50.16 ops/sec ±2.87% (63 runs sampled)
Fastest is Map
*/
var Benchmark = require('benchmark');
var expect = require('expect');
var suite = new Benchmark.Suite;
var test = {
reasons: [],
chunks: []
};
for (var s = 0; s < 5000; s++) {
@Tom910
Tom910 / search.js
Last active February 27, 2017 15:45
var Benchmark = require('benchmark');
var expect = require('expect');
var suite = new Benchmark.Suite;
var test = [];
for (var s = 0; s < 1000000; s++) {
test.push(s);
}
window.onerror = function(message, file, line, column, error) {
var errorToReport = {
type: error ? error.type : '',
message: message,
file: file,
line: line,
column: column,
stack: error ? error.stack : '',
userAgent: navigator.userAgent,
href: location.href
Score
avif - 0.9132000000000002
webp - 0.8198000000000002
higher better