開発環境にDockerを使用しているが、Jestの起動がかなり遅かった。
ファイルのマウントと、複数CPUを使用する辺りで時間がかかっていたようなので、docker/for-mac#1358 を参考に高速化(起動まで60s以上だったのを5sほどに)した。
docker-compose.yml
volumes:
- .:/app
開発環境にDockerを使用しているが、Jestの起動がかなり遅かった。
ファイルのマウントと、複数CPUを使用する辺りで時間がかかっていたようなので、docker/for-mac#1358 を参考に高速化(起動まで60s以上だったのを5sほどに)した。
docker-compose.yml
volumes:
- .:/app
const root = 0; | |
const parentIndex = i => Math.floor((i - 1) / 2); | |
const leftIndex = i => 2 * i + 1; | |
const rightIndex = i => leftIndex(i) + 1; | |
// With Bitwise Operations; | |
// const parentIndex = i => ((i + 1) >>> 1) - 1; | |
// const leftIndex = i => (i << 1) + 1; | |
// const rightIndex = i => (i + 1) << 1; |
// https://github.com/okmttdhr/libuv/blob/8ea8f124386486af2380127c6885848f9d502a36/src/unix/epoll.c#L208-L420 | |
for (;;) { | |
/* Only need to set the provider_entry_time if timeout != 0. The function | |
* will return early if the loop isn't configured with UV_METRICS_IDLE_TIME. | |
*/ | |
if (timeout != 0) | |
uv__metrics_set_provider_entry_time(loop); | |
/* See the comment for max_safe_timeout for an explanation of why | |
* this is necessary. Executive summary: kernel bug workaround. |
import React from "react"; | |
import { MessengerClient } from "./messenger/MessengerServiceClientPb"; | |
interface GRPCClientContextValue { | |
messengerClient?: MessengerClient; | |
} | |
const defaultContextValue = { | |
messengerClient: new MessengerClient(`http://localhost:8080`) | |
}; |
data Tree a = Empty | Node !a !(Tree a) !(Tree a) | |
makeTree :: [a] -> Tree a | |
makeTree xs = fst $ makeTree' (length xs) xs | |
makeTree' :: Int -> [a] -> (Tree a, [a]) | |
makeTree' 0 xs = (Empty, xs) | |
makeTree' n (x:xs) = (Node x l r, zs) | |
where | |
m = n `div` 2 | |
(l, ys) = makeTree' m xs |
export const retry = (fn: () => Promise<any>, timeout = 1000, retries = 5) => | |
new Promise((resolve, reject) => { | |
fn() | |
.then(resolve) | |
.catch(() => { | |
setTimeout(() => { | |
const retriesLeft = retries - 1; | |
if (retries < 0) { | |
return reject('maximum retries exceeded'); | |
} |