Skip to content

Instantly share code, notes, and snippets.

@agreatfool
agreatfool / book.proto
Created February 6, 2018 07:52
Sample proto file
syntax = "proto3";
package com.book;
message Book {
int64 isbn = 1;
string title = 2;
string author = 3;
}
--log_gc (Log heap samples on garbage collection for the hp2ps tool.)
type: bool default: false
--expose_gc (expose gc extension)
type: bool default: false
--max_new_space_size (max size of the new generation (in kBytes))
type: int default: 0
--max_old_space_size (max size of the old generation (in Mbytes))
type: int default: 0
--max_executable_size (max size of executable memory (in Mbytes))
type: int default: 0
$ node -v
v8.4.0
$ node --v8-options | grep gc
--gc_global (always perform global GCs)
--gc_interval (garbage collect after <n> allocations)
--retain_maps_for_n_gc (keeps maps alive for <n> old space garbage collections)
--trace_gc (print one trace line following each garbage collection)
--trace_gc_nvp (print one detailed trace line in name=value format after each garbage collection)
--trace_gc_ignore_scavenger (do not print trace line after scavenger collection)
--trace_gc_verbose (print more details following each garbage collection)
@agreatfool
agreatfool / cpu.go
Created March 26, 2019 06:43
cpu.go
package main
import (
"fmt"
"math/rand"
"net/http"
_ "net/http/pprof"
"runtime"
"time"
)
@agreatfool
agreatfool / memory.go
Last active March 26, 2019 05:53
memory.go
package main
import (
"flag"
"fmt"
"math/rand"
"net/http"
_ "net/http/pprof"
"os"
"runtime"
@agreatfool
agreatfool / event-loop-lag.js
Last active March 15, 2018 09:06
event-loop-lag.js
#!/usr/bin/env node
"use strict";
const interval = 1000; // 采样间隔,即在这个间隔的自然时间内,调用lag()得到的结果将只会得到同样的返回
const lag = require('event-loop-lag')(interval);
function consume() {
function fabonacci(n) {
if (n === 0) {
return 0;
import { Entity, Column, PrimaryGeneratedColumn, Index, BaseEntity } from 'typeorm';
@Entity('test_entity')
@Index('test_entity_index', ['columnB', 'columnC'], { unique: true })
export class TestEntity extends BaseEntity {
@PrimaryGeneratedColumn({ type: 'int', name: 'id' })
id: number;
@Column({ type: 'int', name: 'column_b' })
columnB: number;
Statistical profiling result from isolate-0x103000000-v8.log, (20819 ticks, 582 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
38 0.2% /usr/lib/system/libsystem_malloc.dylib
22 0.1% /usr/lib/system/libsystem_kernel.dylib
9 0.0% /usr/lib/system/libsystem_platform.dylib
4 0.0% /usr/lib/system/libsystem_c.dylib
1 0.0% /usr/lib/system/libsystem_pthread.dylib
{
"name": "profile",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
@agreatfool
agreatfool / book.swagger.json
Created February 6, 2018 07:59
Generated swagger.json
{
"swagger": "2.0",
"info": {
"title": "book/book.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],