Skip to content

Instantly share code, notes, and snippets.

View davidmarkclements's full-sized avatar

David Mark Clements davidmarkclements

View GitHub Profile
@davidmarkclements
davidmarkclements / a.mjs
Last active December 17, 2021 18:31
parent-module ESM
import parentModule from 'parent-module'
console.log(parentModule()) // prints "node:internal/modules/esm/module_job" (Node 16.13.1)
@davidmarkclements
davidmarkclements / snippet-1.sh
Created May 30, 2018 09:13
Keeping Node.js Fast
npm install -g autocannon

Keybase proof

I hereby claim:

  • I am davidmarkclem on github.
  • I am dmclements (https://keybase.io/dmclements) on keybase.
  • I have a public key whose fingerprint is 0DDD 7282 1FEE 2BF0 3D0E EB33 5A03 8B44 115F 07AC

To claim this, I am signing this object:

node 23541 122694113: profile-1ms:
libsystem_kernel.dylib`semaphore_signal_trap+0xa
node`v8::sampler::SamplerManager::DoSample(v8::RegisterState const&)+0xda
node`v8::sampler::SignalHandler::HandleProfilerSignal(int, __siginfo*, void*)+0x72
libsystem_platform.dylib`_sigtramp+0x1a
node`0x26
node`v8::internal::MacroAssembler::RememberedSetHelper(v8::internal::Register, v8::internal::Register, v8::internal::Register, v8::internal::SaveFPRegsMode, v8::internal::MacroAssembler::RememberedSetFinalAction)+0x10b
node`v8::internal::RecordWriteStub::GenerateIncremental(v8::internal::MacroAssembler*, v8::internal::RecordWriteStub::Mode)+0x11c
node`v8::internal::RecordWriteStub::Generate(v8::internal::MacroAssembler*)+0xa0
node`v8::internal::PlatformCodeStub::GenerateCode()+0x9e
node 23305 122461290: profile-1ms:
node`v8::String::Length() const
node`node::BufferValue::BufferValue(v8::Isolate*, v8::Local<v8::Value>)+0x79
node`node::Open(v8::FunctionCallbackInfo<v8::Value> const&)+0x199
node`v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&))+0x164
node`v8::internal::(anonymous namespace)::HandleApiCallHelper(v8::internal::Isolate*, v8::internal::(anonymous namespace)::BuiltinArguments<(v8::internal::BuiltinExtraArguments)3>)+0x6e5
node`v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*)+0x1d1
0x29f3f61060c7
0x29f3f61b08c4
0x29f3f61c1af8
```
node 13846 108328085: profile-1ms:
libsystem_kernel.dylib`__write_nocancel+0xa
libsystem_c.dylib`__sflush+0x57
libsystem_c.dylib`fflush+0x28
node`v8::internal::Log::MessageBuilder::WriteToLogFile()+0x5b
node`v8::internal::Logger::CodeCreateEvent(v8::internal::CodeEventListener::LogEventsAndTags, v8::internal::AbstractCode*, char const*)+0x84
node`v8::internal::(anonymous namespace)::PostBuildProfileAndTracing(v8::internal::Isolate*, v8::internal::Code*, char const*)+0x55
node`v8::internal::SetupIsolateDelegate::SetupBuiltinsInternal(v8::internal::Isolate*)+0x4408
node`v8::internal::Isolate::Init(v8::internal::Deserializer*)+0x2b1e
#!/usr/sbin/dtrace -s
#pragma D option quiet
#pragma D option switchrate=1000hz
profile-1ms /pid == $target/ {
/* Sampling every 1ms therefore also recording timestamp at ms resolution */
printf("%s %d %d: %s:", execname, pid, timestamp / 1000000, probename);
ustack(10000);
printf("\n");
var pino = require('./')
var bole = require('bole')('bench')
var fs = require('fs')
var dest = fs.createWriteStream('/dev/null')
var plog = pino(dest)
require('bole').output({
level: 'info',
stream: dest
}).setFastTime(true)
{"vomicae": "sit et nisi aliqua Lorem eu dolore et consequat officia", "epicarp": "tempor qui consectetur laborum irure cupidatat sunt magna culpa aliquip", "hierarchised": "reprehenderit irure mollit proident est Lorem fugiat cillum id excepteur", "unripened": "proident laborum velit ipsum exercitation sint ut pariatur incididunt non", "enterrologist": "proident irure duis laboris consequat voluptate mollit commodo aliqua nisi", "barterer": "voluptate duis sit voluptate cupidatat duis sit nostrud do magna", "characterless": "ut qui quis et consectetur est quis duis reprehenderit aliqua", "keelless": "deserunt qui dolore id dolore minim commodo eiusmod non quis", "redissolution": "aliqua proident ullamco cupidatat aliqua fugiat ea consequat ea cillum", "scharwenka": "occaecat amet id cupidatat pariatur qui reprehenderit esse anim commodo", "flask": "ex incididunt nulla enim irure culpa ut culpa do deserunt", "methodically": "proident aute mollit pariatur eu ex veniam tempor qui incididunt", "equivalency": "al
const bench = require('fastbench')
function valuesFn (array) {
var i = 0
return function (abort, cb) {
if(i >= array.length)
cb(true)
else
cb(null, array[i++])
}