Skip to content

Instantly share code, notes, and snippets.

@lijinpei
lijinpei / getpid.cpp
Created September 18, 2019 18:18
How many cycles does linux system call takes?
#include <sys/types.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <iostream>
inline unsigned long long rdtsc(void)
{
unsigned hi, lo;
@lijinpei
lijinpei / CMakeLists.txt
Created August 24, 2019 16:59
Test OpenCV Memory Leak
project(test)
cmake_minimum_required(VERSION 3.15)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(cv cv.cpp)
target_link_libraries(cv ${OpenCV_LIBS})
add_executable(cv1 cv1.cpp)
target_link_libraries(cv1 ${OpenCV_LIBS})
@lijinpei
lijinpei / PKGBUILD
Created June 22, 2018 07:42
llvm-git PKGBUILD
# Maintainer: Li Jinpei <leeking1994@163.com>
pkgbase=llvm-git
pkgname=(
'llvm-git'
'clang-git'
)
pkgver=r165875.8e0778c059f
pkgrel=1
test_for_auto_loop:
pushq %rbp
pushq %rbx
subq $8, %rsp
call GetState@PLT
cmpb $0, 26(%rax)
movq %rax, %rbp
je .L2
movq %rax, %rdi
call _ZN9benchmark5State16StartKeepRunningEv@PLT
#include "cache_manager.h"
#include "clang_complete.h"
#include "include_complete.h"
#include "message_handler.h"
#include "project.h"
#include "queue_manager.h"
#include "timer.h"
#include "working_files.h"
#include "clang/Basic/FileManager.h"
#include "message_handler.h"
#include "method.h"
#include "project.h"
#include "queue_manager.h"
#include "timer.h"
#include <loguru.hpp>
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Frontend/ASTUnit.h"
template <class C>
class A {
};
class B {
using A = A<int>;
};
@lijinpei
lijinpei / android-cross.sh
Last active January 14, 2018 05:37
build gcc cross compiler for aarch64
#!/usr/bin/bash
set -e
_target=aarch64-linux
_root_dir=${PWD}
_source_dir=${_root_dir}/source
_host_dir=${_root_dir}/host
_target_dir=${_host_dir}/${_target}
mkdir -p ${_source_dir}
mkdir -p ${_host_dir}
@lijinpei
lijinpei / capture_semantics.cpp
Created January 11, 2018 04:20
runtime by value, static by ref.
#include "benchmark/benchmark.h"
#include <iostream>
using namespace benchmark;
int n = 1;
void func(State &st, int i1) {
std::cerr << i1 << std::endl;
for (auto _ : st) {
@lijinpei
lijinpei / benchmark_non_copyable.cpp
Created January 11, 2018 04:06
benchmark runtime registration won't work with function with non-copyable parameter
#include "benchmark/benchmark.h"
#include <memory>
using namespace benchmark;
void f_movable(State &st, std::unique_ptr<int> pi) {
for (auto _ : st) {
for (int i = 0, i1 = *pi; i < i1; ++i) {
DoNotOptimize(i);
}