Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/oldratlee/hellokt

HelloKt 😸, my kotlin playground 🎡
https://github.com/oldratlee/hellokt

hello-kt kata kotlin modern-tech playground practice

Last synced: 3 months ago
JSON representation

HelloKt 😸, my kotlin playground 🎡

Awesome Lists containing this project

README

        

# HelloKt 😸

My Kotlin playground:

- new kotlin version
- Gradle Kts
- kotest

## Playground

- [🍺 `WeakHashMap`: `ConcurrentModificationException` and `GC`](#-weakhashmap-concurrentmodificationexception-and-gc)
- [🍺 `WeakHashMap`: the copy overhead of `WeakHashMap`](#-weakhashmap-the-copy-overhead-of-weakhashmap)
- [🍺 the queue time of tasks in `ThreadPoolExecutor`](#-the-queue-time-of-tasks-in-threadpoolexecutor)
- [🍺 `AhoCorasickDoubleArrayTrie` performance demo](#-ahocorasickdoublearraytrie-performance-demo)

### 🍺 `WeakHashMap`: `ConcurrentModificationException` and `GC`

when `WeakHashMap` key is `gc`ed in the `WeakHashMap` iteration,
`WeakHashMap` iteration will throw `ConcurrentModificationException`?

Demo Result: NO.

Demo code: [`WeakHashMapGcIteration`](src/test/kotlin/playground/weakhashmap/WeakHashMapGcIteration.kt)

```sh
./gradlew execTestMain -P mainClass=playground.weakhashmap.WeakHashMapGcIterationKt
```

### 🍺 `WeakHashMap`: the copy overhead of `WeakHashMap`

Demo Result: copy ~30M items per second.
test on my MacBookPro16(Intel Core i9).

Demo code: [`WeakHashMapCopyOverheadDemo`](src/test/kotlin/playground/weakhashmap/WeakHashMapCopyOverheadDemo.kt)

```sh
./gradlew execTestMain -P mainClass=playground.weakhashmap.WeakHashMapCopyOverheadDemoKt
```

### 🍺 the queue time of tasks in `ThreadPoolExecutor`

Result:

average queue time = queue size / maximumPoolSize * average task execution time

Demo code: [`TaskQueueTimeThreadPoolExecutorDemo`](src/test/kotlin/playground/threadpool/TaskQueueTimeThreadPoolExecutorDemo.kt)

```sh
./gradlew execTestMain -P mainClass=playground.threadpool.TaskQueueTimeThreadPoolExecutorDemoKt
```

### 🍺 `AhoCorasickDoubleArrayTrie` performance demo

[`AhoCorasickDoubleArrayTrie`](https://github.com/hankcs/AhoCorasickDoubleArrayTrie) performance simple demo.

Result: hit search ~O(1) to the size of search dictionary.

Demo code: [`AhoCorasickDoubleArrayTrieDemo`](src/test/kotlin/playground/text/AhoCorasickDoubleArrayTrieDemo.kt)

```sh
./gradlew execTestMain -P mainClass=playground.text.AhoCorasickDoubleArrayTrieDemoKt
```