Skip to content

Instantly share code, notes, and snippets.

View neon-sunset's full-sized avatar
💭
So ARM64 has FJCVTZS for JS but nothing to count UTF-8 code point length :(

neon-sunset

💭
So ARM64 has FJCVTZS for JS but nothing to count UTF-8 code point length :(
View GitHub Profile
@neon-sunset
neon-sunset / README.md
Last active December 15, 2024 21:10
Quick workflow for using F# interactive to build small native console applications
  1. Get .NET SDK with sudo apt install dotnet9 (or dotnet-sdk-9.0), brew install dotnet for macOS
  2. Get FSharpPacker tool with dotnet tool install -g --allow-roll-forward FSharpPacker
  3. Make an F# interactive script file (e.g. copy the phash.fsx below)
  4. Compile it with fspack {your-script.fsx} -f net9.0 -o {destination} --aot
    (in this example: fspack phash.fsx -f net9.0 -o . --aot), note that it will take some time to do so for the first time - .NET needs to fetch IL AOT Compiler from Nuget
  5. Profit! You have compiled an F# script to a native binary
  6. (Optional) If you add fspk.fish, the process is simplified to fspk {my-script}.fsx!

Note 1: if you are not using macOS or FreeBSD, give https://github.com/ieviev/fflat a try which can produce even smaller binaries

@neon-sunset
neon-sunset / NBody.cs
Created September 12, 2024 01:11
BenchmarksGame NBody submission (#3?)
// The Computer Language Benchmarks Game
// https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
//
// Based on Swift program #3 by Ralph Ganszky
using System.Runtime.CompilerServices;
using Body = (
(double X, double Y, double Z) P,
(double X, double Y, double Z) V, double M);
@neon-sunset
neon-sunset / Mandelbrot.cs
Last active September 6, 2024 21:08
BenchmarksGame mandelbrot contribution
// The Computer Language Benchmarks Game
// https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
//
// direct transliteration of Greg Buchholz's C program
// contributed by Isaac Gouy, fix by David Turnbull
// dispatching to multiple cores, use SIMD operationn, early break
// depending on previous depth by Patrick Stein,
// direct transliteration of Swift #7 program by Arseniy Zlobintsev
using System.Runtime.CompilerServices;
@neon-sunset
neon-sunset / Cargo.toml
Last active September 9, 2024 12:45
Наївне порівняння вартості асинхронних примітивів поміж C#, Go та Elixir
[package]
name = "tasks"
version = "0.1.0"
edition = "2021"
[dependencies]
futures = "0.3.30"
tokio = { version = "1.40.0", features = ["full"] }
@neon-sunset
neon-sunset / Fasta.cs
Created August 29, 2024 01:46
Fasta Rust #7 -> C#
// The Computer Language Benchmarks Game
// https://salsa.debian.org/benchmarksgame-team/benchmarksgame/
//
// contributed by the Rust Project Developers
// contributed by TeXitoi
// contributed by Alisdair Owens
// contributed by Ryohei Machida
// adapted to C# by Arseniy Zlobintsev
using System.Runtime.CompilerServices;
@neon-sunset
neon-sunset / .editorconfig
Last active October 29, 2024 01:33
Terse C# Style Guide #2
[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
# Microsoft .NET properties
@neon-sunset
neon-sunset / BinaryTrees.cs
Last active August 12, 2024 12:04
Comparison of Go and C# AOT in BinaryTrees microbenchmark extracted from BenchmarksGame
// The Computer Language Benchmarks Game
// https://benchmarksgame-team.pages.debian.net/benchmarksgame/
//
// based on
// - Tristan Dupont Java #7
// - Anthony Lloyd C#
// - Isaac Guoy C# #7
// - Steve (hez2010) https://github.com/dotnet/runtime/issues/101006#issue-2241502984
// contributed by Arseniy Zlobintsev
@neon-sunset
neon-sunset / BinaryTrees.cs
Last active August 9, 2024 20:57
Optimized contribution of Binary Trees benchmark for BenchmarksGame suite
// The Computer Language Benchmarks Game
// https://benchmarksgame-team.pages.debian.net/benchmarksgame/
//
// based on
// - Tristan Dupont Java #7
// - Anthony Lloyd C#
// - Isaac Guoy C# #7
// - Steve (hez2010) https://github.com/dotnet/runtime/issues/101006#issue-2241502984
// contributed by Arseniy Zlobintsev
@neon-sunset
neon-sunset / dotnet.md
Last active July 30, 2024 00:33
Oberon investigation on Mono 6.12.0 vs CoreCLR 9.0.100-preview.7.24375.5

Starting DeltaBlue benchmark ... DeltaBlue: iterations=640000 average: 3us total: 2403826us

Starting Richards benchmark ... Richards: iterations=2000 average: 1388us total: 2777930us

Starting Json benchmark ... Json: iterations=8000 average: 435us total: 3480222us

Starting Havlak benchmark ...

@neon-sunset
neon-sunset / .editorconfig
Last active June 30, 2024 23:42
Trying out a terser C# style
# Remove the line below if you want to inherit .editorconfig settings from higher directories
root = true
# C# files
[*.cs]
#### Core EditorConfig Options ####
# Indentation and spacing
indent_size = 4