Skip to content

Instantly share code, notes, and snippets.

View sharkdp's full-sized avatar

David Peter sharkdp

View GitHub Profile
@sharkdp
sharkdp / todo.cpp
Created March 30, 2021 12:59
A todo() macro for C++, inspired by Rusts todo!()
#include <iostream>
struct todo_statement {
public:
todo_statement(const char* file, const int line)
: m_file(file), m_line(line) {}
template <typename T>
operator T() {
std::cerr << "Error: Remove todo() statement in " << m_file << ":" << m_line
@sharkdp
sharkdp / benchmark-just-exit.sh
Created December 12, 2020 09:38
just-exit benchmark
echo "int main() {}" > just-exit.c
gcc -O just-exit.c -o just-exit-c
echo "" > just-exit.py
echo "fn main() {}" > just-exit.rs
rustc -O just-exit.rs -o just-exit-rs
echo "" > just-exit.rb
# Configuration for Alacritty, the GPU enhanced terminal emulator
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty it self.
env:
# TERM env customization.
#
# If this property is not set, alacritty will set it to xterm-256color.
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#!/usr/bin/python
import argparse
import json
import matplotlib.pyplot as plt
parser = argparse.ArgumentParser()
parser.add_argument("results", help="JSON file with benchmark results")
args = parser.parse_args()
#!/bin/bash
# the root directory for the search
base_path="$HOME" # CHANGE THIS
if ! which bench > /dev/null 2>&1; then
echo "'bench' does not seem to be installed."
echo "You can get it here: https://github.com/Gabriel439/bench"
exit 1
fi
#!/bin/bash
trap "tput reset; tput cnorm; exit" 2
clear
tput civis
lin=2
col=$(($(tput cols) / 2))
c=$((col-1))
color=0
tput setaf 2; tput bold
@sharkdp
sharkdp / cold-cache.sh
Last active October 7, 2017 20:13
fd benchmark scripts
echo "This script will now ask for your password in order to gain root/sudo"
echo "permissions. These are required to reset the harddisk caches."
echo ""
sudo echo "Okay, acquired superpowers :-)" || exit
base_path="/mnt/daten"
pattern='.*[0-9]\.jpg$'
for _ in $(seq 1 3); do
#pragma once
extern double pi;
@sharkdp
sharkdp / insect-type-safety.md
Last active August 24, 2017 19:59
Type-safety in physics calculations

Type-safety in physics calculations

This article describes a (loose?) analogy between physical units and data types in programming languages that I thought about while working on Insect, a scientific calculator that supports physical units.

In addition to typical mathematical operators like +, *, ^, %, etc., Insect has a special conversion operator (written as an arrow ->/ or as the word to). It can be used to convert an expression to a particular unit:

≫ 2 ft + 2 in ➞ cm

  = 66.04 cm