Skip to content

Instantly share code, notes, and snippets.

View kaixiong's full-sized avatar

Chong Kai Xiong kaixiong

View GitHub Profile
@kaixiong
kaixiong / mem-set-benchmark-16.cpp
Last active March 4, 2023 11:05
visual_mem_set{16,32} benchmarks - C vs ASM vs Intrinsics
// -*- compile-command: "clang++ -O2 -Wall -std=c++20 -fstrict-aliasing -o mem-set-benchmark-16 mem-set-benchmark-16.cpp $(pkg-config --cflags --libs fmt)" -*-
#include <array>
#include <bit>
#include <chrono>
#include <iostream>
#include <memory>
#include <utility>
#include <cassert>
#include <cstddef>
@kaixiong
kaixiong / mem_benchmark.cpp
Created February 23, 2023 14:01
LV vs SSE2 vs glibc memset/memcpy
// -*- compile-command: "g++ -O2 -Wall -std=c++20 -fstrict-aliasing -o mem-benchmark mem-benchmark.cpp $(pkg-config --cflags --libs fmt)" -*-
#include <bit>
#include <chrono>
#include <iostream>
#include <memory>
#include <utility>
#include <cassert>
#include <cstddef>
#include <cstdint>
@kaixiong
kaixiong / mem-benchmark.cpp
Last active February 22, 2023 18:33
LV vs glibc memset/memcpy
// -*- compile-command: "g++ -O2 -Wall -std=c++20 -fstrict-aliasing -o mem-benchmark mem-benchmark.cpp $(pkg-config --cflags --libs fmt)" -*-
#include <bit>
#include <chrono>
#include <iostream>
#include <memory>
#include <utility>
#include <cassert>
#include <cstddef>
#include <cstdint>
<?php
// Usage: icon_letters.php?FN=symbol&L=m&L_B=250&L_R=00&L_G=150&BG_B=100&BG_R=150&BG_G=250
// Usage: icon_letters.php?FN=kaiu&dx=-3&dy=0&BG_B=100&BG_R=100&L=陈
$width_height = 320;
//Send a generated image to the browser
$LETTERS_MAX_LEN = 3;
$letters = "SDP";
if (isset($_GET['L'])) {
@kaixiong
kaixiong / random
Last active December 20, 2015 02:38
Benchmarks of various ways to generate random numbers in a given range
#include <cstdint>
#include <ctime>
#include <random>
#include <boost/format.hpp>
#define RUN_COUNT 100000
#define RANGE_MIN 100
#define RANGE_MAX 100000
typedef std::minstd_rand PRNG;
@kaixiong
kaixiong / gist:4708432
Created February 4, 2013 18:12
lv-tool valgrind full memory leak check
==9979== Memcheck, a memory error detector
==9979== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==9979== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==9979== Command: /home/kaixiong/installs/libvisual-0.5/bin/lv-tool
==9979==
/home/kaixiong/installs/libvisual-0.5/bin/lv-tool - libvisual-0.5.0 (257c138-dirty) commandline tool - http://libvisual.org
==9979==
==9979== HEAP SUMMARY:
==9979== in use at exit: 108,336 bytes in 538 blocks
==9979== total heap usage: 3,933 allocs, 3,395 frees, 1,837,113 bytes allocated
kaixiong@dreamerbox:~/Documents/projects/libvisual/libvisual/build$ lv-tool -i pulseaudio -f 0
lv-tool v0.1
Loading actor 'lv_analyzer'...
Loading input 'pulseaudio'...
0.15332912
0.00005442
0.00007324
0.00004757
0.15461316
0.00004697
kaixiong@dreamerbox:~/Documents/projects/libvisual$ git pull
remote: Counting objects: 100, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 40 (delta 27), reused 40 (delta 27)
Unpacking objects: 100% (40/40), done.
From github.com:Libvisual/libvisual
dd5ac7a..ae678da cxx -> origin/cxx
Updating dd5ac7a..ae678da
Fast-forward
libvisual-plugins/plugins/input/jack/input_jack.cpp | 33 ++++++++++++++-------------------
#include <libvisual/libvisual.h>
#include <pulse/simple.h>
#include <pulse/error.h>
#include <boost/format.hpp>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstdlib>
typedef std::vector<LV::Time> TimingProfile;
#include "config.h"
#include "lv_ringbuffer.h"
#include "lv_common.h"
#include "gettext.h"
#include <vector>
namespace LV {
namespace {