Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Groostav's full-sized avatar

Geoff Groostav

View GitHub Profile
@Groostav
Groostav / JavaSwitchExpressions.java
Created September 11, 2023 16:17
attempt 2 at benchmarking different switch types
package org.example;
public class JavaSwitchExpressions {
public static int intSwitchExpression(Node node) {
return switch(node.typeInt()){
case 0 -> ((Node.FirstNodeType) node).firstId();
case 1 -> ((Node.SecondNodeType) node).secondId();
case 2 -> ((Node.ThirdNodeType) node).thirdId();
case 3 -> ((Node.FourthNodeType) node).fourthId();
@Groostav
Groostav / SwitchBenchmarks.java
Created September 6, 2023 23:13
attempting to performance profile forms java switch expressions
package org.example;
import org.openjdk.jmh.annotations.*;
import java.util.concurrent.TimeUnit;
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
@Warmup(iterations = 5, time = 5)
@Measurement(iterations = 5, time = 1)
parser = argparse.ArgumentParser()
parser.addArgument('--print-metadata')
subparsers = parser.add_subparsers(dest='command')
subparsers.add_parser(name='build')
subparsers.add_parser(name='predict')
parsed_args = parser.parse_args()
match vars(parsed_args):
@Groostav
Groostav / dumb-dsl.kt
Last active March 1, 2023 22:46
An attempt to create a statically-checked "domain-path" type
sealed interface PathTrace<out T> {
val elements: List<Nodable>
class Composite(override val elements: List<Nodable>): PathTrace<Nothing>
open class Empty: PathTrace<Nothing> {
override val elements: List<Nodable> get() = emptyList()
}
}
@Groostav
Groostav / output_log.txt
Last active June 6, 2022 21:56
"prop counting failure!" w/ traffic light replacer on load & when changing light set.
This file has been truncated, but you can view the full file.
Initialize engine version: 5.6.7f1 (e80cc3114ac1)
GfxDevice: creating device client; threaded=1
Direct3D:
Version: Direct3D 11.0 [level 11.1]
Renderer: AMD Radeon RX 5700 XT (ID=0x731f)
Vendor: ATI
VRAM: 8151 MB
Driver: 30.0.13023.4001
Begin MonoManager ReloadAssembly
Platform assembly: H:\SteamLibrary\steamapps\common\Cities_Skylines\Cities_Data\Managed\UnityEngine.dll (this message is harmless)
@Groostav
Groostav / DoubleArrayHashList.kt
Created October 12, 2021 20:01
a first crack at an implementation of a reasonably compact matrix with fast indexOf(row) and contains(row) operations
package com.empowerops.jargon.model.opt2
import java.lang.IndexOutOfBoundsException
/**
* Why, why on gods green earth would you implement this geoff!?
*
* Ok, after studying the access patterns, we need fast contains and fast indexOf.
* fast contains is easily provided by hashMap,
* to get indexOf, you want a NavigableSet (indexOf(elem) == headSet(elem).size)
package com.empowerops.visualizer;
import com.empowerops.common.*;
import com.empowerops.common.eventbus.EventBus;
import com.empowerops.common.ui.FXController;
import com.empowerops.common.ui.FXMLLoader;
import com.empowerops.dal.OptimizationMetadata;
import com.empowerops.dal.OptimizationModel;
import com.empowerops.jargon.OptimizerService;
import com.empowerops.jargon.events.NewExpensivePointFoundEvent;
@Groostav
Groostav / More-Testing-Try-Catch.ps1
Last active October 9, 2020 20:28
what is powershells Stop-Process doing
Write-Host "Host Version:" $Host.Version
Try
{
Write-Host "before!"
Stop-Process 123456789 -EA Stop
Write-Host "after!"
}
Catch
{
@Groostav
Groostav / code.kt
Last active November 27, 2019 01:11
@FXML fun onRunButtonClick(): Job {
println("clicked... launch coming")
val job = launch(Dispatchers.Default + CoroutineName("Run-button-click")) {
println("launched!")
}
println("launched, job=$job")
Platform.runLater {
println("Platform.runlater: running later, job=$job")
Caused by: java.nio.file.NoSuchFileException: C:\Users\Inhal\AppData\Roaming\OASIS 2020.1\licenses\trial-license.l4j
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53)
at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38)
at sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:193)
at java.nio.file.Files.readAttributes(Files.java:1737)
at java.nio.file.Files.size(Files.java:2332)
at com.empowerops.front_end.LicenseImportingServiceImpl$findLicenseCacheSources$2.invokeSuspend(LicenseImportingService.kt:142)