Skip to content

Instantly share code, notes, and snippets.

@Ruikuan
Ruikuan / Program.cs
Last active October 8, 2019 14:06
CorrelationIdGenerator.GenerateId Benchmark
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
using System.Runtime.InteropServices;
namespace GenerateIdBenchmark
{
class Program
{
static void Main(string[] args)
@Ruikuan
Ruikuan / BenchmarkDictAndConcurrentDic.cs
Last active May 3, 2022 09:03
Benchmark Dictionary and ConcurrentDictionary
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Collections.Concurrent;
var summary = BenchmarkRunner.Run(typeof(Program).Assembly);
class Helper
{
public static string Repeat(string str, int count)
{
@Ruikuan
Ruikuan / Program.cs
Last active July 13, 2022 12:28
Sign certificate on the fly
using System.Collections.Concurrent;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
ConcurrentDictionary<string, X509Certificate2> _certificates = new ConcurrentDictionary<string, X509Certificate2>();
var rootCertPath = "root.pem";
var rootKeyPath = "key.pem";
var rootCert = X509Certificate2.CreateFromPemFile(rootCertPath, rootKeyPath); // initialize the root certificate