Skip to content

Instantly share code, notes, and snippets.

@paroj
paroj / gtkogre.cpp
Created September 23, 2022 20:50
Ogre3D GTK integration
/*-------------------------------------------------------------------------
This source file is a part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@paroj
paroj / launch.json
Last active January 25, 2022 13:52
{
// 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": [
@paroj
paroj / vulkan.cpp
Created September 8, 2021 14:56
minimal vulkan.hpp with SDL2
#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);
#!/bin/sh
# 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
paroj / genasm.mk
Created October 15, 2017 21:57
generate asm
g++ -std=c++11 -O3 -S -masm=intel -fverbose-asm main.cpp # -mllvm --x86-asm-syntax=intel
@paroj
paroj / zero.cpp
Created March 7, 2017 13:02
memory allocation performance
#include <cstring>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <vector>
#define NITER 100//5000000
int main() {
clock_t t;
@paroj
paroj / strconv.cpp
Created March 7, 2017 12:59
performance of string conversions
#include <cstring>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstdlib>
#include <sstream>
#define NITER 5000000
int main() {
@paroj
paroj / clobber.c
Last active March 7, 2017 13:01
clobber: force code generation for benchmarking
// gcc -O3 -S -masm=intel -fverbose-asm test.c
// (code : out : in : clobber)
asm volatile ("" :: "g"(&a) : "memory");
// see also: https://www.youtube.com/watch?v=nXaxk27zwlk