Skip to content

Instantly share code, notes, and snippets.

View Nucs's full-sized avatar

Eli Belash Nucs

  • Haifa, Israel
View GitHub Profile
@Nucs
Nucs / MultiKeyDictionary.cs
Last active April 1, 2024 20:18
A technique to define a dictionary with any kind of keys combination, supporting items with N keys and M keys. All works as long as they implement Equals and GetHashcode, or using IEquitable
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
var specificCombinationDictionary = new MultikeyDictionary<(int,int), string>();
specificCombinationDictionary[(1, 2)] = "3";
var anyKeyDictionary = new MultikeyDictionary<ITuple, string>();
anyKeyDictionary[(1, 2)] = "3";
anyKeyDictionary[("str", DateTime.UtcNow.Date)] = "undefined err";
anyKeyDictionary[(1, 3, 5, "what? a string?!", ("sub?", "Tuple??"))] = "undefined err";
@Nucs
Nucs / MemoryInflator.cs
Created June 9, 2022 10:20
Memory Inflating Tool used to allocate memory while preventing windows RAM compression and disk caching
using System.Runtime.InteropServices;
var alloc = new Allocation();
Console.WriteLine("Hey, this tool will allocate how much memory you'll type in and reallocate ");
try {
Task.Run(async () => {
while (true) {
await Task.Delay(60000).ConfigureAwait(false);
if (!alloc.Buffer.HasValue)
continue;
@Nucs
Nucs / issue400.cs
Last active September 29, 2019 12:29
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RegenTesting
{
class Shape
{
using System.Runtime.InteropServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using NumSharp.Backends;
using NumSharp.Backends.Unmanaged;
using NumSharp.Memory.Pooling;
using NumSharp.Utilities;
namespace NumSharp.Benchmark.Unmanaged
{
import numpy as np
errors = 0
rights = 0
outputShapes = list()
def operator_(left, right, msg):
global errors, rights, outputShapes
print("")
using System;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using NumSharp.Backends.Unmanaged;
using NumSharp.Memory.Pooling;
using NumSharp.Utilities;
namespace NumSharp.Benchmark.Unmanaged
{
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
namespace OMath.Benchmarks
{
//| Method | Mean | Error | StdDev | Median | Min | Max | Ratio | RatioSD |
//|--------------------------------------- |----------:|----------:|----------:|----------:|----------:|----------:|------:|--------:|
//| BasicClass | 2.542 us | 0.0209 us | 0.0299 us | 2.526 us | 2.516 us | 2.613 us | 1.00 | 0.00 |
//| InterfacedClass | 2.535 us | 0.0116 us | 0.0173 us | 2.528 us | 2.517 us | 2.570 us | 1.00 | 0.01 |
[MinColumn, MaxColumn, MeanColumn, MedianColumn]
[SimpleJob(launchCount: 1, warmupCount: 3, targetCount: 15)]
public class ParallelFor {
private const int iterations = 10;
private int largeSize = 50_000;
DArray<int> a;
DArray<int> b;
private ParallelOptions settingsDistributed;
private ParallelOptions settingsConcurrent;
[SimpleJob(RunStrategy.ColdStart, targetCount: 20)]
[SimpleJob(RunStrategy.Throughput, targetCount: 20)]
[MinColumn, MaxColumn, MeanColumn, MedianColumn]
[HtmlExporter]
public unsafe class GetSpan {
private const int length = 100_000;
private const int iterations = 20_000;
private UnmanagedArray<int> from;
private Vector<int> fromvec;