Skip to content

Instantly share code, notes, and snippets.

View ljwagerfield's full-sized avatar
🚀

Lawrence Wagerfield ljwagerfield

🚀
View GitHub Profile
@ljwagerfield
ljwagerfield / ProfilingMemoryUsageJVM.md
Last active February 19, 2019 16:33
Profiling Memory Usage (JVM)

Profiling Memory Usage of a Method (JVM)

Prerequisites:

  • YourKit

Steps:

  1. Add Thread.sleep(60000) to the START and END of the method you want to profile.
case class Product(id: Int, price: Int, inStock: Boolean)
case class Basket(productIds: List[Int])
trait ProductRepo {
def getProduct(productId: Int): Product
}
trait ShoppingBasketRepo {
@ljwagerfield
ljwagerfield / functions
Created September 15, 2016 12:18
Amazon Linux init.d Functions
# -*-Shell-script-*-
#
# functions This file contains functions to be used by most or all
# shell scripts in the /etc/init.d directory.
#
TEXTDOMAIN=initscripts
# Make sure umask is sane
umask 022
def run() = {
import scala.concurrent.{ blocking, ExecutionContext, Future }
implicit val ec = ExecutionContext.fromExecutor(java.util.concurrent.Executors.newFixedThreadPool(1))
val startTime = System.nanoTime()
def event(name: String) =
Console.println(s"t=${(System.nanoTime - startTime) / 1000000000}s | $name")
event("REPORT request RCVD")
val candidates = 1 to 10
def run() = {
import scala.concurrent.{ blocking, ExecutionContext, Future }
implicit val ec = ExecutionContext.fromExecutor(java.util.concurrent.Executors.newFixedThreadPool(1))
val startTime = System.nanoTime()
def event(name: String) =
Console.println(s"t=${(System.nanoTime - startTime) / 1000000000}s | $name")
event("REPORT request RCVD")
val candidates = 1 to 10