Skip to content

Instantly share code, notes, and snippets.

View Aschen's full-sized avatar
💭
:trollface:

Adrien Maret Aschen

💭
:trollface:
View GitHub Profile
@Aschen
Aschen / README.md
Last active May 3, 2023 11:23
Benchmarking AsyncLocalStorage

What is the overhead of AsyncLocalStorage?

Run the benchmark:

$ npm i benchmark

# Run the AsyncLocalStorage benchmark
$ node async-local-storage.js ASL
ASL x 15,551 ops/sec ±3.30% (79 runs sampled)
@Aschen
Aschen / int32_vs_float64.cr
Created March 29, 2020 04:45
Int32 vs Float64 performances in Crystal
# https://stackoverflow.com/questions/60910274/int32-vs-float64-performances-in-crystal
require "benchmark"
def percentage_diff(number_a, number_b)
small_number = (number_a > number_b) ? number_b : number_a
big_number = (number_a < number_b) ? number_b : number_a
(big_number - small_number) / small_number
end
@Aschen
Aschen / results.txt
Last active February 12, 2020 02:40
Benchmark returning promises
node bench/returning-promises.js
standard x 3,096,388 ops/sec ±0.77% (91 runs sampled)
async wrapped x 1,853,672 ops/sec ±1.12% (81 runs sampled)
await then return x 1,074,238 ops/sec ±1.96% (53 runs sampled)
Fastest is standard
@Aschen
Aschen / README.md
Last active February 10, 2020 03:01
Benchmarking Kuzzle Realtime Engine latency

Benchmarking Kuzzle Realtime Engine latency

Run the subscriber script:

node realtime-latency-benchmark.js sub

Then you can run publisher scripts:

node realtime-latency-benchmark.js pub
@Aschen
Aschen / benchmark.js
Created January 14, 2020 09:23
Closur optim
const
PipeRunner = require('./pipeRunner');
const now = (unit) => {
const hrTime = process.hrtime();
switch (unit) {
case 'milli':
@Aschen
Aschen / benchmark.js
Created January 14, 2020 07:08
Closur optim
const
PipeRunner = require('./pipeRunner');
const now = (unit) => {
const hrTime = process.hrtime();
switch (unit) {
case 'milli':
@Aschen
Aschen / assign-vs-destructuring.js
Created December 6, 2019 15:39
Benchmarking merging object
const Benchmark = require('benchmark')
const _ = require('lodash');
const suite = new Benchmark.Suite
const obj1 = {
nested: {
object: {
value: 'string'
}
@Aschen
Aschen / loop-append-array.js
Last active November 29, 2019 08:53
Benchmarking append values to arrays
const Benchmark = require('benchmark')
const suite = new Benchmark.Suite
const array = [];
for (let i = 0; i < 1000; i++) {
array.push({ value: i });
}
@Aschen
Aschen / access-vs-destructuring.js
Last active November 29, 2019 04:11
Benchmarking object destructuring
const Benchmark = require('benchmark')
const _ = require('lodash');
const suite = new Benchmark.Suite
const obj = {
value: 42,
name: 'jean',
not: 'taked'
};
@Aschen
Aschen / loop-create-array.js
Last active November 29, 2019 08:53
Benchmarking creating array from array
const Benchmark = require('benchmark')
const suite = new Benchmark.Suite
const array = [];
for (let i = 0; i < 1000; i++) {
array.push({ value: i });
}