Skip to content

Instantly share code, notes, and snippets.

View bgrainger's full-sized avatar

Bradley Grainger bgrainger

View GitHub Profile
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Diagnostics.CodeAnalysis;
using System.Text;
var summary = BenchmarkRunner.Run<Lookups>();
[MemoryDiagnoser]
public class Lookups
{
using MySqlConnector;
using System.Diagnostics;
var threadCount = args.Length == 1 && int.TryParse(args[0], out var tc) ? tc : 100;
var csb = new MySqlConnectionStringBuilder
{
Server = // REDACTED
UserID = // REDACTED
Password = // REDACTED
using Dapper;
using MySqlConnector;
await MethodToRunAsync();
async Task Method1Async()
{
using (var domain = new MySqlConnection())
{
await domain.OpenDBAsync();
@bgrainger
bgrainger / About.md
Last active March 21, 2021 05:10
Reading Portable PDBs with System.Reflection.Metadata

Reading Embedded Portable PDBs

This example shows how to read an embedded portable PDB file using the System.Reflection.Metadata classes.

static readonly object s_lock = new object();
static readonly SemaphoreSlim s_semaphore = new SemaphoreSlim(1);
static int s_data;
[Benchmark]
public int Lock()
{
lock (s_lock)
{
s_data++;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace System.Runtime.CompilerServices
{
internal static class RuntimeHelpers
{
/// <summary>
/// Slices the specified array using the specified range.
User Input Bing Suggestion
man msn
Yah Yahoo
prostrate prostate
pray city party city
hard rich heaven hard rock heaven
ten virgin teen virgin
free born free porn
@bgrainger
bgrainger / !results.md
Last active August 8, 2019 14:13
Benchmarking MySqlConnector DbBatch against MariaDB

MySQL 8.0.17

Method Mean Error StdDev
Command 403.4 µs 7.959 µs 19.069 µs
Commands 775.9 µs 15.357 µs 28.465 µs
PreparedCommand 359.8 µs 4.708 µs 4.174 µs
PreparedCommands 726.8 µs 14.508 µs 14.899 µs
BatchCommand 390.2 µs 7.572 µs 7.776 µs
BatchCommands 390.5 µs 7.548 µs 10.077 µs
@bgrainger
bgrainger / ReadFileFragment.cpp
Created June 3, 2019 17:50
Improving WPF Text Display Performance
HRESULT FontFileStream::ReadFileFragment(const void ** fragmentStart, UINT64 fileOffset, UINT64 fragmentSize, void ** fragmentContext)
{
if (fragmentStart != nullptr)
*fragmentStart = nullptr;
if (fragmentContext != nullptr)
*fragmentContext = nullptr;
if (fragmentStart == nullptr || fragmentContext == nullptr)
return E_POINTER;
if (fileOffset >= m_length || fileOffset + fragmentSize > m_length)
return E_INVALIDARG;
@bgrainger
bgrainger / ReservedWords.cs
Created September 12, 2018 15:56
MySQL 8 reserved words
var reservedWords = new[]
{
"ACCESSIBLE",
"ADD",
"ALL",
"ALTER",
"ANALYZE",
"AND",
"AS",
"ASC",