Skip to content

Instantly share code, notes, and snippets.

View H4ad's full-sized avatar

Vinicius Lourenço H4ad

View GitHub Profile
@H4ad
H4ad / trace-events.log
Created April 6, 2024 12:38
Trace Events for NPM CLI (npm run empty)
{"traceEvents":[{"pid":23143,"tid":23143,"ts":2188920482,"tts":24728,"ph":"b","cat":"node,node.debuglog_module_cjs","name":"require('/home/h4ad/Projects/opensource/performance-analysis/npm-cli/bin/npm-cli.js')","dur":0,"tdur":0,"id":"0x0","args":{}},{"pid":23143,"tid":23143,"ts":2188921608,"tts":25782,"ph":"b","cat":"node,node.debuglog_module_cjs","name":"require('../lib/cli.js')","dur":0,"tdur":0,"id":"0x0","args":{}},{"pid":23143,"tid":23143,"ts":2188922313,"tts":26189,"ph":"b","cat":"node,node.debuglog_module_cjs","name":"require('./es6/validate-engines.js')","dur":0,"tdur":0,"id":"0x0","args":{}},{"pid":23143,"tid":23143,"ts":2188922628,"tts":26418,"ph":"b","cat":"node,node.debuglog_module_cjs","name":"require('../../package.json')","dur":0,"tdur":0,"id":"0x0","args":{}},{"pid":23143,"tid":23143,"ts":2188923234,"tts":26876,"ph":"e","cat":"node,node.debuglog_module_cjs","name":"require('../../package.json')","dur":0,"tdur":0,"id":"0x0","args":{}},{"pid":23143,"tid":23143,"ts":2188923246,"tts":26888,"ph":"e
@H4ad
H4ad / is-ipv4-from-csharp.js
Created September 21, 2023 11:18
I tried to convert the C# generated code to Javascript, and it failed :/
class superRunner {
runtextpos = 0;
runstack = new Array(16);
}
const isBetween05 = new Map([
['0', true]
['1', true]
['2', true]
['3', true]
function memoryUsed() {
gc();
const mbUsed = process.memoryUsage().heapTotal / 1024 / 1024;
return mbUsed;
}
function getRandomString() {
// stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
return (
Math.random().toString(36).substring(2, 15) +
@H4ad
H4ad / tp.yml
Last active February 28, 2023 23:04
TP Template
# the description that will be shown during "tp list"
description: "My simple template"
# Where we can get this template
# installUrl:
# commands that will be read by tp
generate:
# name of your resource
# this will be exposed like: tp generate setup <name>
@H4ad
H4ad / benchmark.js
Created February 4, 2023 19:32
Node Postgres Array Performance Analysis
var Benchmark = require('benchmark');
var array = require('postgres-array');
var fasterArray = require('./faster-postgres-array');
function parseBool (value) {
if (value === null) return value
return value === 'TRUE' ||
value === 't' ||
value === 'true' ||
value === 'y' ||
@H4ad
H4ad / benchmark.ts
Last active February 4, 2023 15:26
Module Token Factory Performance Analysis v2
var Benchmark = require('benchmark');
import { DynamicModule } from '@nestjs/common';
import { Type } from '@nestjs/common/interfaces/type.interface';
import { randomStringGenerator } from '@nestjs/common/utils/random-string-generator.util';
import {
isFunction, isSymbol
} from '@nestjs/common/utils/shared.utils';
import { ModuleTokenFactory } from '@nestjs/core/injector/module-token-factory';
import { createHash } from 'crypto';
import stringify from 'fast-safe-stringify';
@H4ad
H4ad / README.md
Last active January 21, 2023 16:17
NestJS Module Token Factory

NestJS Performance Analysis

This is the artifact of my performance analysis on NestJS about ModuleTokenFactory.

@H4ad
H4ad / README.md
Created January 15, 2023 06:29
Object Hash Performance Analysis

This file was used to perform a performance analysis on object-hash.

To run, copy all files to a folder, initilize the NPM with npm init, then install:

npm i --save benchmark object-hash
@H4ad
H4ad / README.md
Last active January 12, 2023 17:43
Fast ISO String Generation

Results:

fromUnixToISOString x 3,258,470 ops/sec ±1.86% (85 runs sampled)
new Date().toISOString() x 1,408,158 ops/sec ±0.96% (90 runs sampled)
@H4ad
H4ad / benchmark.ts
Created January 8, 2023 15:14
Ogma Benchmark
// to run this file, install: npm i --save benchmark pino @ogma/logger @nestjs/common
// and then just run with: npx ts-node benchmark.ts
import { Logger } from '@nestjs/common';
import { Ogma } from '@ogma/logger';
import pino from 'pino';
import * as Benchmark from 'benchmark';
const suite = new Benchmark.Suite();