Skip to content

Instantly share code, notes, and snippets.

@kuniyoshi
kuniyoshi / measure how four arithmetic operations are.
Created April 30, 2016 08:40
performance of four arithmetic operations
#include <iostream>
#include "benchmark/benchmark.h"
using namespace std;
const int MaxSize = 1 << 24;
const double* init_numbers(int);
const double* Numbers = init_numbers(MaxSize);
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int get_size(int depth)
{
int r = 0;
@kuniyoshi
kuniyoshi / plot_g_transition_by_height_from_the_earth.R
Created February 10, 2016 06:33
重力加速度(g)変化、地表からの距離
z.g <- 6.67259e-11
z.m <- 5.972e24
z.r <- 6.356752314e6
z.fg <- function(h) z.g * z.m / (h + z.r)^2
curve(z.fg, from = 0, to = 1e7, xlab = "h[m]", ylab = "g[m/s2]", ylim = c(0, 10))
abline(v = 400e3)
@kuniyoshi
kuniyoshi / ranking.2016-01
Created January 19, 2016 21:06
特訓期間のランキングボーダー推移 (2016-01)
date_time r500 r1000 r2000 r3000 r4000 r5500 r7500 r10000 r15000 r20000 r20200 r30000 r30200 r50000 r50100 r100000 r150000 r200000 my_score my_ranking
2016-01-18T20:58:32 31911 24990 21378 18821 17460 16469 15574 14846 11636 9997 9969 8222 8205 6287 6281 3161 647 1 10052 19647
2016-01-18T21:02:26 31972 25062 21437 18872 17515 16502 15610 14893 11657 10016 9991 8234 8217 6296 6290 3167 648 1 10052 19752
2016-01-18T21:12:03 32130 25101 21493 18922 17553 16552 15658 14943 11678 10029 10006 8245 8226 6306 6300 3173 649 1 10052 19836
2016-01-18T21:22:01 32242 25169 21592 18968 17615 16598 15706 14993 11693 10048 10024 8254 8239 6314 6309 3181 650 1 10052 19968
2016-01-18T21:32:31 32373 25205 21657 19011 17652 16647 15755 15033 11715 10072 10043 8266 8251 6324 6318 3186 651 1 10052 20138
2016-01-18T21:42:09 32507 25274 21755 19069 17683 16694 15802 15066 11745 10090 10065 8277 8263 6333 6327 3192 652 1 10086 20017
2016-01-18T21:51:45 32624 25323 21826 19113 17734 16726 15853 15106 11786 10110 10083 8290 8274 6342 6
@kuniyoshi
kuniyoshi / acquisition
Last active January 18, 2016 00:11
acquisition
DateTime FilesChanged Insertions Deletions NewFiles NewLines Errors CompiledDateTime LinkedDateTime
2016-01-18T07:59:00 23 509 124 8 844 103 2016-01-18T09:01:00 2016-01-18T09:08:00
2016-01-12T21:04:00 14 345 73 6 535 42 2016-01-12T21:37:00 2016-01-12T21:37:00
2016-01-06T11:57:00 10 140 24 8 333 41 2016-01-06T12:46:00 2016-01-06T12:46:00
2015-12-23T16:48:00 6 34 13 49 1864 72 2015-12-23T20:23:00 2015-12-23T21:14
2015-12-17T14:17:00 4 11 1 2 166 16 2015-12-17T14:38:00 2015-12-17T14:38:00
2015-12-16T08:32:00 7 125 232 13 371 88 2015-12-16T09:17:00 2015-12-16T09:17:00
2015-12-14T22:28:00 5 58 78 6 274 49 2015-12-14T22:38:00 2015-12-14T22:38:00
2015-12-13T07:31:00 9 226 308 2 71 55 2015-12-13T08:09:00 2015-12-13T08:09:00
2015-12-11T15:59:00 1 11 0 0 0 0 2015-12-11T15:59:00 2015-12-11T15:59:00
#!/bin/bash
cat \
| grep error \
| awk '{print$1}' \
| sort \
| uniq \
| wc -l
@kuniyoshi
kuniyoshi / count_diff.sh
Last active December 23, 2015 01:01
count diff
#!/bin/bash
date +%FT%T
git diff --stat 2>/dev/null | tail -1
git status --untracked-files=all \
| awk '/Untracked files/{p=1} p {print $1}' \
| awk '/\.cpp$/ { print$1 } /\.h$/ { print$1 }' \
| xargs wc \
| awk '/\.cpp$/{++count} /\.h$/{++count} /total/{print count, "new files", $1, "new lines"}'
@kuniyoshi
kuniyoshi / alpha_blend.cpp
Created December 9, 2015 07:26
アルファブレンドの高速化
#include <iostream>
#include <random>
#include "benchmark/benchmark.h"
#define WARN(x) warn(#x, x, __FILE__, __LINE__)
using namespace std;
template< class T >
void warn(const char* exp, T value, const char* filename, const int line)
@kuniyoshi
kuniyoshi / plus_vs_or.cpp
Created December 7, 2015 08:03
算術和と論理和との比較
#include <iostream>
#include "benchmark/benchmark.h"
using namespace std;
unsigned char* be_byte(unsigned v)
{
unsigned char* b = new unsigned char[sizeof(unsigned)];
for (int i = 0; i < sizeof(unsigned); ++i) {
@kuniyoshi
kuniyoshi / abench.cpp
Created December 2, 2015 10:03
ビット数を探索する方法の比較です。
#include <iostream>
#include "benchmark/benchmark.h"
using namespace std;
const unsigned HEAP_REGION_SIZE_BIT = 24;
unsigned getBitNumber( unsigned a ){
//二分検索でビット数を確定
unsigned first = 0;