Skip to content

Instantly share code, notes, and snippets.

@hiroyukim
hiroyukim / gist:a3878843e22d4f857d6378652ac21bc8
Created June 10, 2021 04:36
fast main.go:3 slow main.go:10
0x0000 00000 (main.go:3) SUBQ $24, SP 0x0000 00000 (main.go:10) SUBQ $24, SP
0x0004 00004 (main.go:3) MOVQ BP, 16(SP) 0x0004 00004 (main.go:10) MOVQ BP, 16(SP)
0x0009 00009 (main.go:3) LEAQ 16(SP), BP 0x0009 00009 (main.go:10) LEAQ 16(SP), BP
0x000e 00014 (main.go:3) FUNCDATA $0, gclocals·1a65e721a2ccc325b382662e7ffee780(SB) 0x000e 00014 (main.go:10) FUNCDATA $0, gclocals·1a65e721a2ccc325b382662e7ffee780(SB)
0x000e 00014 (main.go:3) FUNCDATA $1, gclocals·69c1753bd5f81501d95132d08af04464(SB) 0x000e 00014 (main.go:10) FUNCDATA $1, gclocals·69c1753bd5f81501d95132d08af04464(SB)
0x000e 00014 (main.go:4) MOVQ "".s+56(SP), CX 0x000e 00014 (main.go:11) MOVQ "".s+56(SP), DX
0x0013 00019 (main.go:4) MOVQ "".a+48(SP), DX 0x0013 00019 (main.go:11) MOVQ "".a+32(SP), BX
0x0018 00024 (main.go:4) CMPQ CX, DX 0x0018 00024 (main.go:11) MOVQ "".a+40(SP), SI
0x001b 00027 (main.go:4) JHI 60 0x001d 00029 (main.go:11) XORL AX, AX
0x001d 00029 (main.go:5) MOVQ "".a+32(SP), AX 0x001f 00031 (main.go:11) NOP
#!/bin/env ruby
require "google_drive"
require 'date'
require 'dotenv/load'
session = GoogleDrive::Session.from_config("config.json")
# Uploads a local file.
session.upload_from_file(ENV["FILE_PATH"], Date.today.strftime('%Y%m%d'), convert: false)
require 'benchmark'
ary = []
ary2 = []
ary3 = []
Benchmark.bm 10 do |r|
r.report "+" do
10000.times { |n| ary += [n] }
end
r.report "push" do
def level(exp)
level = 1
return level if exp == 0
while true do
next_level = level + 1
level_exp = (10 *(1.7 **level -1.7)/0.7).to_int
next_level_exp = (10 *(1.7 **next_level -1.7)/0.7).to_int
if level_exp < exp && exp <= next_level_exp then
use strict;
use warnings;
my @results;
sub functional_number {
my $num = shift;
if( $results[$num] ) {
return $results[$num];
use strict;
use warnings;
use Data::Dumper;
my @hoge = qw/aa dd ee ff/;
my %hash = (
test => @hoge,
);
use strict;
use warnings;
use utf8;
use feature "switch";
# map 生成
my @map;
my $MAP_SIZE = 35;
my $iter = sub {
use strict;
use warnings;
use utf8;
use Web::Query;
use NetAddr::IP;
my @ips;
wq(q{http://www.nttdocomo.co.jp/service/developer/smart_phone/technical_info/etc/index.html})
->find('#maincol div:nth-child(4) div .delmb')
->each(sub{
@hiroyukim
hiroyukim / fluentd
Created October 30, 2012 06:05 — forked from higebu/fluentd
/etc/init.d/fluentd
#!/bin/bash
PID_FILE=/var/run/fluentd.pid
CONF_FILE=/etc/fluent/fluent.conf
LOG_FILE=/var/log/fluent/fluent.log
PSNAME="fluentd --daemon"
F_USER=fluentd
F_GROUP=fluentd
RUBY_VER="1.9.3-p194"
@hiroyukim
hiroyukim / Handler.pm
Created January 31, 2012 15:12 — forked from riywo/Handler.pm
Amon2::Plugin::DBIx::Handler
use strict;
use warnings;
use utf8;
package Amon2::Plugin::DBIx::Handler;
use DBIx::Handler;
sub init {
my ($class, $context_class, $config) = @_;