Using perf:
$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg
NOTE: See @GabrielMajeri's comments below about the
-g
option.
SESSION_NAME=ope | |
if [[ -z "$TMUX" && -z "$STY" ]] && type tmux >/dev/null 2>&1; then | |
option="" | |
if tmux has-session -t ${SESSION_NAME}; then | |
option="attach -t ${SESSION_NAME}" | |
else | |
option="new -s ${SESSION_NAME}" | |
fi | |
tmux $option && exit |
$ time python test.py | |
real 0m0.148s | |
user 0m0.133s | |
sys 0m0.019s |
Using perf:
$ perf record -g binary
$ perf script | stackcollapse-perf.pl | rust-unmangle | flamegraph.pl > flame.svg
NOTE: See @GabrielMajeri's comments below about the
-g
option.
- 切った後の長方形の数 = 切り分けた線分の数 + 1 なので、線分の数を数えることにする。 | |
- 線分は周囲に3つのブロックがある格子点を端点に持っている。 | |
- 周囲に3つのブロックがある格子点を凹点と呼ぶことにする。 | |
- 全てのピースが長方形であるということは凹点が存在しないということ。 | |
- 線分の数は凹点の数でおさえられる。 | |
- 凹点同士を結ぶ線分が多ければ多いほどよい。 | |
- 線分の数 = 凹点の数 - 凹点同士を結ぶ線分の数 | |
- 凹点同士を結ぶ線分を1本引くと2つの凹点を潰すことが出来るため | |
- 凹点同士を結ぶ線分を2本交わるように引いても4つの凹点を潰したことにはならない。 | |
- 1本目の線分を引いた時点で多角形が切り分けられ、2本目は凹点同士を結ぶ線分にならない。 |
#!/usr/bin/env python | |
# | |
# Decompressor/compressor for files in Mozilla's "mozLz4" format. Firefox uses this file format to | |
# compress e. g. bookmark backups (*.jsonlz4). | |
# | |
# This file format is in fact just plain LZ4 data with a custom header (magic number [8 bytes] and | |
# uncompressed file size [4 bytes, little endian]). | |
# | |
# This Python 3 script requires the LZ4 bindings for Python, see: https://pypi.python.org/pypi/lz4 | |
# |
#!/bin/bash | |
set -eu | |
# Topcoder MM の実行可能ファイルのパス | |
# 一時ファイルは /workdir に置くといいらしい | |
TEMP_PATH="/workdir/a.out" | |
rm -f submission.zip | |
cargo clean |
use anyhow::Result; | |
use reqwest::ClientBuilder; | |
use serde::Deserialize; | |
use std::collections::{HashMap, HashSet}; | |
#[tokio::main] | |
async fn main() -> Result<()> { | |
let client = ClientBuilder::new().gzip(true).build()?; | |
let models: HashMap<String, ProblemModel> = client | |
.get("https://kenkoooo.com/atcoder/resources/problem-models.json") |
use anyhow::Result; | |
use reqwest::ClientBuilder; | |
use scraper::{Html, Selector}; | |
use serde::Deserialize; | |
use std::collections::{HashMap, HashSet}; | |
#[tokio::main] | |
async fn main() -> Result<()> { | |
let client = ClientBuilder::new().gzip(true).build()?; | |
let cookie = "..."; |
use std::fs::read_to_string; | |
use chrono::{DateTime, FixedOffset, NaiveDate, TimeZone, Utc}; | |
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; | |
#[derive(Debug)] | |
struct RawEvent { | |
start: Option<DateTime<FixedOffset>>, | |
end: Option<DateTime<FixedOffset>>, |