Skip to content

Instantly share code, notes, and snippets.

View kumagi's full-sized avatar
:octocat:
Fine.

Hiroki KUMAZAKI kumagi

:octocat:
Fine.
View GitHub Profile
@kumagi
kumagi / pythonmemcache.py
Created November 15, 2011 13:42
pythonから使えるmemcachedクライアントの比較(シングルスレッド)
import time
def bench(fn):
begin = time.time()
fn()
return time.time() - begin
n = 100000
def setwork(cl):
for i in range(0, n):
@kumagi
kumagi / virtual_memory_limit.c
Last active October 29, 2023 07:39
mmap_max
#include <memory.h>
#define _XOPEN_SOURCE_EXTENDED 1
#include <sys/mman.h>
#include <stdint.h>
#include <stdio.h>
#include <climits>
#include <algorithm>
int main() {
@kumagi
kumagi / LICENSE.txt
Last active August 23, 2023 00:43
spinlockのベンチマーク
Copyright 2023 Hiroki Kumazaki
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 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR O
@kumagi
kumagi / LICENSE.txt
Last active August 4, 2023 15:33
とても簡単なリングバッファ
Copyright 2023 Hiroki Kumazaki
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 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR O
wait-free/lock-free/obstruction-freeの定義について
▲全てに共通する概念
スレッドが他のスレッドの進行を禁止する事がないので、どれかのスレッドが
ロックを確保したままプリエンプションなどで全体の処理が停止する事態が発生しな
い。
これは必ずしもロックベースのアルゴリズムより高速であることを意味し
ない(現にロックの方が早い場合もある
wait-freeが一番強い条件で、それを弱める度に

Name

JP: 熊崎 宏樹 EN: Kumazaki Hiroki

Department

search, Google

Title

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
class BIT {
public:
explicit BIT(size_t n) : tree(n + 2) {}
@kumagi
kumagi / blue_particle.go
Created June 14, 2021 02:27
青い●がいっぱい動くサンプル
package main
import (
"log"
"time"
"image/color"
"golang.org/x/image/font"
"golang.org/x/image/font/opentype"
"math/rand"
lld/build$ cmake -G Ninja ..
CMake Error at CMakeLists.txt:6 (string):
string sub-command REGEX, mode MATCH needs at least 5 arguments total to
command.
-- LLD version:
CMake Error at CMakeLists.txt:10 (string):
string sub-command REGEX, mode REPLACE needs at least 6 arguments total to
command.
@kumagi
kumagi / lockfree::queue.hpp
Created April 22, 2010 18:26
lockfree queue without hazard pointer
#ifndef LOCKFREE_QUEUE
#define LOCKFREE_QUEUE
#include "atomics.h"
#include <unistd.h> // usleep
#include <stdlib.h> // rand
namespace lockfree{
template<typename T>