Skip to content

Instantly share code, notes, and snippets.


Pavel Rojtberg paroj

View GitHub Profile
paroj / clobber.c
Last active Mar 7, 2017
clobber: force code generation for benchmarking
View clobber.c
// gcc -O3 -S -masm=intel -fverbose-asm test.c
// (code : out : in : clobber)
asm volatile ("" :: "g"(&a) : "memory");
// see also:
paroj / strconv.cpp
Created Mar 7, 2017
performance of string conversions
View strconv.cpp
#include <cstring>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <sstream>
#define NITER 5000000
int main() {
paroj / zero.cpp
Created Mar 7, 2017
memory allocation performance
View zero.cpp
#include <cstring>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <vector>
#define NITER 100//5000000
int main() {
clock_t t;
paroj /
Created Oct 15, 2017
generate asm
g++ -std=c++11 -O3 -S -masm=intel -fverbose-asm main.cpp # -mllvm --x86-asm-syntax=intel
# compile with -fno-omit-frame-pointer
# usermode
sudo sh -c "echo 0 > /proc/sys/kernel/kptr_restrict"
sudo sh -c 'echo 1 >/proc/sys/kernel/perf_event_paranoid'
# record with callgraph
perf record -g $1
# display with inverse callgraph
perf report -g 'graph,0.5,caller'
paroj / vulkan.cpp
Created Sep 8, 2021
minimal vulkan.hpp with SDL2
View vulkan.cpp
#include <SDL2/SDL.h>
#include <SDL2/SDL_vulkan.h>
#include <vulkan/vulkan.hpp>
#include <algorithm>
VkBool32 debug_callback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT messageTypes,
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void* pUserData)
auto types = vk::to_string((vk::DebugUtilsMessageTypeFlagsEXT)messageTypes);
View launch.json
// launch python through GDB to break in CPP code
"version": "0.2.0",
"configurations": [
"name": "GDB Python: Current File",
"type": "cppdbg",
"request": "launch",
"program": "/usr/bin/python",
"args": [