Skip to content

Instantly share code, notes, and snippets.

View eleniums's full-sized avatar

Stan Nelson eleniums

View GitHub Profile
@eleniums
eleniums / Makefile
Last active April 4, 2024 00:10
Sample Go Makefile to build binaries for Windows, Mac, and Linux.
EXECUTABLE=executable-name
WINDOWS=$(EXECUTABLE)_windows_amd64.exe
LINUX=$(EXECUTABLE)_linux_amd64
DARWIN=$(EXECUTABLE)_darwin_amd64
VERSION=$(shell git describe --tags --always --long --dirty)
.PHONY: all test clean
all: test build ## Build and run tests
@eleniums
eleniums / pprof_cpu.sh
Created May 4, 2019 17:23
Script to run pprof for a cpu profile.
#!/usr/bin/env bash
set -e
# INSTRUCTIONS:
# Run benchmark tests first (test_bench.sh) to generate a cpu profile.
# First parameter of this script is the index to use (samples or cpu).
# USEFUL PPROF COMMANDS:
# top - Outputs the top entries (can also do top10 or top20 or topN where N is any number to limit results).
# list - Shows method code with flat and cum values.
@eleniums
eleniums / pprof_mem.sh
Created May 4, 2019 17:23
Script to run pprof for a memory profile.
#!/usr/bin/env bash
set -e
# INSTRUCTIONS:
# Run benchmark tests first (test_bench.sh) to generate a memory profile.
# First parameter of this script is the index to use (alloc_space, alloc_objects, inuse_space, or inuse_objects).
# Alloc indexes track total allocations over time. Inuse tracks current in-memory usage.
# USEFUL PPROF COMMANDS:
# top - Outputs the top entries (can also do top10 or top20 or topN where N is any number to limit results).
@eleniums
eleniums / test_bench.sh
Last active May 4, 2019 17:22
Script to run benchmarks for Go.
#!/bin/bash
set -e
if [ -z "$BENCH_TIME" ]
then
export BENCH_TIME=10s
fi
if [ -z "$BENCH" ]
then