Surprisingly on Apple M2 (ARM) atomic is inferior to mutex.
g++ -std=c++20 -O3 atomic_vs_mutex_cnt.cpp -pthread
python3 run_counter.py > counter_perf.csv
pip3 install pandas seaborn
python3 plot.py
see result in mutex_vs_atomic_m2_chart.png
# run streamlit run pid_streamlit.py | |
# matplotlib==3.7.1 | |
# streamlit==1.43.2 | |
import matplotlib.pyplot as plt | |
import streamlit as st | |
class PidController: | |
def __init__(self, ki=1, kp=1, kd=1, target=0): | |
self.ki = ki |
Surprisingly on Apple M2 (ARM) atomic is inferior to mutex.
g++ -std=c++20 -O3 atomic_vs_mutex_cnt.cpp -pthread
python3 run_counter.py > counter_perf.csv
pip3 install pandas seaborn
python3 plot.py
see result in mutex_vs_atomic_m2_chart.png
license: mit |
import time | |
import tqdm | |
import numpy as np | |
import multiprocessing as mp | |
def mix_observations(observations: np.ndarray): | |
indices = np.random.randint(0, len(observations), size=len(observations)) | |
new_sample = observations[indices] |
class Color: | |
""" | |
https://misc.flogisoft.com/bash/tip_colors_and_formatting | |
https://gist.github.com/dmitryhd/68f2a71fb2832643217c17e61a78b214 | |
""" | |
COLOR = '\033[' | |
BOLD = '\033[1m' | |
RESET = '\033[0m' | |
DIM = '\e[2m' | |
BLINK = '\e[5m' |
import sys | |
import os | |
import json | |
import tqdm | |
import pandas as pd | |
class LabelEncoder: | |
class LabelEncoder: | |
def __init__(self): | |
self._values2index = {} | |
self._next_index = 0 | |
self._index2value = {} | |
def encode(self, value) -> int: | |
if value in self._values2index: | |
return self._values2index[value] |