Skip to content

Instantly share code, notes, and snippets.

View puzpuzpuz's full-sized avatar
🐢

Andrei Pechkurov puzpuzpuz

🐢
View GitHub Profile
@Deleplace
Deleplace / mapfunc_test.go
Created November 17, 2022 13:01
Is there a performance penalty when taking a func argument instead of a value argument, in concurrent maps operations?
package mapfunc
import (
"sync"
"testing"
"github.com/puzpuzpuz/xsync/v2"
)
const (
$ curl 'http://169.254.169.254/latest/meta-data/instance-type'
c6g.metal
$ go version
go version go1.19.3 linux/arm64
$ go test -run='^$' -cpu=1,2,4,8,16,32,64 -bench . -count=30 -timeout=0 | tee bench.txt
$ benchstat bench.txt | tee benchstat.txt
@love8587
love8587 / logger.ts
Created January 31, 2020 15:34
NodeJs - Logging with tracer ID using cls-hooked (No need to pass the tracer ID as a parameter)
import { createLogger, format, transports } from 'winston';
const { combine, timestamp, label, splat, printf, colorize, json } = format;
import requestTracer from '../helpers/request-tracer';
const defaultFormat = printf(
({ level = 'debug', message = '', label = 'default', timestamp, payload = {} }) => {
let payloadStr = '';
try {
payloadStr = JSON.stringify(payload);
} catch (err) {
@wentout
wentout / AsyncStorageMixContextTest.js
Last active December 15, 2019 06:55
Some thoughts about async storage context for PR 26540
"use strict";
const common = require("../common");
const assert = require("assert");
const { AsyncContext } = require("async_hooks");
const asyncContext = new AsyncContext();
const tasks = [];
asyncContext.enter(store => {
@duarten
duarten / Combiner.java
Created October 25, 2016 19:48
Flat combining
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
public final class Combiner {
public interface Action {
public void apply();
}
private static final class Node {
@robertpainsi
robertpainsi / README.md
Last active September 18, 2024 19:52
How to reopen a pull-request after a force-push?

How to reopen a pull-request after a force-push?

Precodinitions

  • You need the rights to reopen pull requests on the repository.
  • The pull request hasn't been merged, just closed.

Instructions

  1. Write down the current commit hash of your PR-branch git log --oneline -1 <PR-BRANCH>
  2. Write down the latest commit hash on github before the PR has been closed.
  3. git push -f origin :
@apangin
apangin / StringHash.java
Created September 2, 2015 13:24
Compare xxHash with default String.hashCode
package bench;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import sun.misc.Unsafe;
import java.lang.reflect.Field;