負荷ベンチマークツール wrk てシンプルで良いなあ

👉 WordPress で cf-cache-status: BYPASS のままで HIT にならない

シンプルで使いやすい感じ。


❯ wrk -v
wrk 4.2.0 [kqueue] Copyright (C) 2012 Will Glozer
Usage: wrk <options> <url>
  Options:
    -c, --connections <N>  Connections to keep open
    -d, --duration    <T>  Duration of test
    -t, --threads     <N>  Number of threads to use

    -s, --script      <S>  Load Lua script file
    -H, --header      <H>  Add header to request
        --latency          Print latency statistics
        --timeout     <T>  Socket/request timeout
    -v, --version          Print version details

  Numeric arguments may include a SI unit (1k, 1M, 1G)
  Time arguments may include a time unit (2s, 2m, 2h)


❯ wrk https://android.benigumo.com
Running 10s test @ https://android.benigumo.com
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   237.81ms  226.51ms   1.77s    88.62%
    Req/Sec    27.29     15.51    70.00     61.59%
  480 requests in 10.05s, 47.63MB read
  Socket errors: connect 0, read 0, write 0, timeout 2
Requests/sec:     47.77
Transfer/sec:      4.74MB

Lua とか合わせて使えるらしいので便利だろうと思えます。

👉 wg/wrk: Modern HTTP benchmarking tool


Jetpack Compose で Activity を取得する

なんとなくまだ古くさい感じはありますが。


val context = LocalContext.current


fun Context.getActivityOrNull(): Activity? {
    var context = this
    while (context is ContextWrapper) {
        if (context is Activity) return context
        context = context.baseContext
    }    
    return null
}


fun Context.findActivity(): Activity {
    var context = this
    while (context is ContextWrapper) {
        if (context is Activity) return context
        context = context.baseContext
    }
    throw IllegalStateException("Permissions should be called in the context of an Activity")
}

👉 android - How to get activity in compose - Stack Overflow


【Kotlin】バージョンカタログ libs.versions.toml の記述だるくね? module 記述のほうが良くね?

なんか面倒なだけな気がしてきた。


hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" }

group, name より、

module 記述で良くないか。


hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" }

まあ、無駄に几帳面に書いてました。

こんなにスッキリ。

👉 Pokedex/gradle/libs.versions.toml at main · skydoves/Pokedex