Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View zezba9000's full-sized avatar

Andrew zezba9000

  • For Fun Labs
  • Bellevue, WA
View GitHub Profile

Removing C# stack copies syntactically

A proposal that eliminates stack copies at the heart of C type'ish languages like C# when using 'structs' (aka value types) heavily as is done in image manipulation, graphics in general, physics, games, Unity3D, etc (I'm sure there are many more fields as well).

Key arguments for this feature

  • 40% .NET Core & Framework performance increase on i3-7100 using this benchmark with 'USE_OUT' enabled: Link
    • Performance increase could actually be higher if the code complexity increased.
    • Not yet tested but guessing even a bigger gain on ARM SoC.
  • Allows one to describe vector based algorithms in C# as you do in HLSL, GLSL, CG, etc without performance loss due to stack copies.
  • You can maintain operator 'precedence' in vector math as is done with primitive types in C#.
  • Doesn't break older C# or .NET runtime versions.
@zezba9000
zezba9000 / LightMapSwitcher.cs
Last active July 31, 2018 18:26
Unity LightMapSwitcher
using UnityEngine;
using System;
using System.IO;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
[Serializable]
@zezba9000
zezba9000 / SimpleHTTPServer.cs
Created June 19, 2017 01:36 — forked from aksakalli/SimpleHTTPServer.cs
SimpleHTTPServer in C#
// Modified from: https://gist.github.com/aksakalli/9191056
using System;
using System.Collections.Generic;
using System.Net;
using System.IO;
using System.Threading;
namespace MyNamespace
{
@zezba9000
zezba9000 / HTTPServer.cs
Last active March 13, 2023 11:52
HTTP C# server
// Modified from: https://gist.github.com/aksakalli/9191056
using System;
using System.Collections.Generic;
using System.Net;
using System.IO;
using System.Threading;
namespace MyNamespace
{
@zezba9000
zezba9000 / .cs
Created March 26, 2017 00:14
C# Threaded Jobs
using System;
using System.Threading;
namespace ThreadJobs
{
abstract class Job : IDisposable
{
private Thread thread;
private volatile bool waiting;
@zezba9000
zezba9000 / launch.json
Last active June 28, 2016 17:06
VS Code
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/bin/Debug/netcoreapp1.0/hwapp.dll",
"args": [],
@zezba9000
zezba9000 / VTableMethodHooking.cpp
Last active October 11, 2018 02:08
VTable Method hooking
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;
class Base
{
public:
virtual void foo(int i)
`INFO =======================================================`
`File Ext = '.rl'`
`NOTE: This lang compiles out to other lang targets such as C, Nim, C#, Java, javaScript, etc`
`The lang utalizes the native GC in each target. If a GC doesn't exist a simple one capabled of running on Arduino to PC will be implemented`
`This lang is strong typed, supports runtime type info and objects/classes are linked via namespace over file location (like C#)`
`There are two primary goals with this lang
#1 portability (Arduino'ish devices with 1kb or less of ram to PCs with GBs of ram) [Almost any CPU should work out of the box with code gen targets]
#2 performance (targets like Nim [deterministic GC] and C will get you this)`