Skip to content

Instantly share code, notes, and snippets.

View martinus's full-sized avatar
😎
warp! Help, I'm trapped in a time

Martin Leitner-Ankerl martinus

😎
warp! Help, I'm trapped in a time
View GitHub Profile
@martinus
martinus / .bashrc
Created May 4, 2018 07:59
awesome bash prompt
function prompt_timer_start {
PROMPT_TIMER=${PROMPT_TIMER:-`date +%s.%3N`}
echo -ne "\033]0;${@}\007"
}
function prompt_svn_stats() {
command -v svn >/dev/null
if [ $? != 0 ]; then
return
fi
@martinus
martinus / random_bool_benchmark.cpp
Last active October 15, 2019 05:42
fast random bool in C++
#include <algorithm>
#include <chrono>
#include <iostream>
#include <random>
#define LIKELY(x) __builtin_expect((x), 1)
#define UNLIKELY(x) __builtin_expect((x), 0)
#define NO_INLINE __attribute__((noinline))
// extremely fast random number generator that also produces very high quality random.
@martinus
martinus / benchmark.cpp
Created July 25, 2019 05:55
simple benchmark of tsl, robin_hood, and std::unordered_map
#include <iostream>
#include <string>
#include <chrono>
#include <unordered_map>
#include "tsl/robin_map.h"
#include "robin_hood.h"
using namespace std;
using my_clock = std::chrono::high_resolution_clock;
@martinus
martinus / benchmark2.cpp
Created July 27, 2019 10:53
simple benchmark of robin_hood map, updated
#include <iostream>
#include <string>
#include <chrono>
#include <unordered_map>
#include "tsl/robin_map.h"
#include "robin_hood.h"
using my_clock = std::chrono::high_resolution_clock;

Build with g++4-8, the oldest supported

CC=gcc-4.8 CXX=g++-4.8 CPPFLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 ./configure --disable-wallet
@martinus
martinus / perf.md
Last active October 24, 2023 15:12
perf config

/etc/sysctl.conf

kernel.perf_event_paranoid = -1
kernel.perf_cpu_time_max_percent = 5
kernel.perf_cpu_time_max_percent=10000
@martinus
martinus / .tmux.conf
Created September 25, 2019 11:09
Linux Configurations
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
set-option -g history-limit 10000
# Enable mouse mode (tmux 2.1 and above)
setw -g mouse on
# remap prefix from 'C-b' to 'C-Space'
unbind C-b

Warning, results might be unstable:

  • NDEBUG not defined, assert() macros are evaluated
  • CPU governor is '' but should be 'performance'

Recommendations

ns/op op/s err% ins/op cyc/op IPC total benchmark
#pragma once
#include <bitset>
#include <type_traits>
namespace util {
// Provides a type-safe bitset for enums
template <typename E>
class EnumFlags {
class UpToExecutor {
public:
UpToExecutor(int64_t begin, int64_t end, int64_t step)
: mBegin(begin)
, mEnd(end)
, mStep(step) {}
template <typename Op>
void operator()(Op op) {