Skip to content

Instantly share code, notes, and snippets.

@hohonuuli
hohonuuli / ifdo-to-fathomnet.sc
Last active May 26, 2022 01:26
Proof-of-concept to convert https://marine-imaging.com/fair/ifdos/iFDO-overview/ to FathomNet-friendly CSV
#!/usr/bin/env -S scala-cli shebang --scala-version 3.1.2
/*
Proof of concept to convert iFDO YAML to FathomNet CSV
Requirements:
- Install scala-cli https://scala-cli.virtuslab.org
Usage:
ifdo-to-fathomnet.sc <ifdo-yaml-file> > <fathomnet-csv-file>
@hohonuuli
hohonuuli / Logging.scala
Created May 2, 2022 16:33
Gist for Medium article
import java.lang.System.Logger
import java.lang.System.Logger.Level
import java.util.function.Supplier
/**
* * @author Brian Schlining
*/
object Logging:
case class LoggerBuilder(
@hohonuuli
hohonuuli / build_m1.sh
Last active March 16, 2022 19:35
Example build script for docker containers on M1/Arm
#!/usr/bin/env bash
echo "--- Building vars-kb-server (reminder: run docker login first!!)"
VCS_REF=`git tag | sort -V | tail -1`
docker buildx build --platform linux/amd64,linux/arm64 \
-t mbari/vars-kb-server:${VCS_REF} \
-t mbari/vars-kb-server:latest \
--push . \
@hohonuuli
hohonuuli / Logging.scala
Last active February 3, 2022 20:30
Simple pass through logger
import java.lang.System.Logger
import java.lang.System.Logger.Level
object Logging:
private def logAndReturn[T](obj: T, logger: Logger, level: Level, fn: T => String): T =
if logger.isLoggable(level) then
logger.log(level, fn(obj))
obj
@hohonuuli
hohonuuli / Transformer.scala
Last active November 2, 2021 20:30
Method to convert case classes to CSV
import java.net.URL
import scala.deriving.*
import scala.compiletime.{summonAll}
import java.nio.file.Path
/**
* Base function we use to convert case classes to CSV
* @param a The object to convert
*/
def transform[A : Transformer](a: A) = summon[Transformer[A]].f(a)
@hohonuuli
hohonuuli / fetch_async.scala
Last active October 25, 2021 19:39
Scala version of python download code in Medium article
#!/usr/bin/env scala
/*
@author Brian Schlining
@since 2021-10-25
Scala version of example code at
https://python.plainenglish.io/send-http-requests-as-fast-as-possible-in-python-304134d46604
*/
@hohonuuli
hohonuuli / scala3_microservices_autocannon2_results.csv
Last active September 25, 2021 22:36
Statistics for Medium Article on Scala 3 microservice benchmarks - autocannon2
Metric Cask Helidon http4s Javalin Scalatra Spark Java Vert.x Web ZIO Http
autocannon 2
latency (ms) 244.59 238.96 292.62 300.87 240.99 268.99 145.06 230.14
latency std (ms) 25.51 20.57 127.78 33.52 14.88 28.32 6.57 45.18
requests/sec 4058.55 4154.36 3856.9 3294.7 4119.7 3689.6 6850.6 4312.95
requests/sec std 210.95 191.57 166.87 85.13 96.84 124.06 104.82 116.38
transfer/sec (MB) 34.19 34.87 32.38 27.26 34.54 31.18 57.20 36.18
transfer/sec std 1.77 1.61 1.40 0.71 0.81 1.05 0.87 0.97
relative transfer % 59.8 61.0 56.6 47.7 60.4 54.5 100 63.3
@hohonuuli
hohonuuli / scala3_microservices_autocannon1_results.csv
Last active September 25, 2021 22:33
Statistics for Medium Article on Scala 3 microservice benchmarks - autocannon1
Metric Cask Helidon http4s Javalin Scalatra Spark Java Vert.x Web ZIO Http
autocannon 1
latency (ms) 88.24 85.73 117.73 110.23 92.85 87.15 144.81 82.97
latency std (ms) 27.12 20.05 50.39 57.82 15. 36.8 6.49 23.6
requests/sec 11258.4 11579.2 9860.5 9362.8 10766.8 11433.6 6862.4 11961.6
requests/sec std 650.2 313.8 454.5 669.11 476.44 344.42 105.55 244.63
transfer/sec (MB) 94.85 97.23 82.78 77.46 90.28 96.64 57.30 100.37
transfer/sec std 5.48 2.62 3.82 5.53 4.00 2.90 0.88 2.05
relative transfer % 94.5 96.9 82.5 77.2 89.9 96.3 57.1 100
@hohonuuli
hohonuuli / scala3_microservices_wrk2_results.csv
Last active September 26, 2021 18:40
Statistics for Medium Article on Scala 3 microservice benchmarks - wrk2
Framework latency_ms latency_ms_std requests_sec mb_sec pct_max
Cask 61.76 7.16 4022.49 33.89 58.1
Helidon 57.33 7.45 4333.65 36.39 62.4
http4s 65.57 75.05 3928.46 32.98 56.6
Javalin 82.35 21.99 2959.23 24.48 42.0
Scalatra 58.34 3.88 4253.52 35.67 61.2
SparkJava 59.90 27.87 3347.74 28.30 48.6
Vert.xWeb 35.61 1.25 6980.19 58.29 100
ZIOHttp 57.03 6.46 4346.36 35.47 60.9
@hohonuuli
hohonuuli / scala3_microservice_wrk1_results.csv
Last active September 26, 2021 00:05
Statistics for Medium Article on Scala 3 microservice benchmarks - wrk1
Framework latency_ms latency_ms_std requests_sec mb_sec pct_max
Cask 22.15 4.72 11221.20 94.55 92.6
Helidon 21.25 3.39 11698.15 98.23 96.2
http4s 24.75 26.02 10460.28 87.82 86.1
Javalin 29.01 28.36 8765.20 72.52 71.1
Scalatra 21.97 2.25 11274.22 94.54 92.5
Spark Java 22.82 23.59 11273.21 95.29 93.4
Vert.x Web 36.75 3.50 6765.11 56.49 55.3
ZIO Http 20.42 1.59 12162.62 102.06 100