This is the artifact of my performance analysis on NestJS about ModuleTokenFactory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class superRunner { | |
runtextpos = 0; | |
runstack = new Array(16); | |
} | |
const isBetween05 = new Map([ | |
['0', true] | |
['1', true] | |
['2', true] | |
['3', true] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' || |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
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
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |
NewerOlder