Skip to content

Instantly share code, notes, and snippets.

[HideColumns("Error", "StdDev", "Median", "RatioSD")]
[Config(typeof(Config))]
public class StringReverseBench
{
public List<string> List;
public IEnumerable<string> Enumerable;
[Params(true, false)] // Arguments can be combined with Params
public bool UseList;
[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net80)]
public class StringSegmentVsStringSplitter
{
private const string Phrase = "A quick brown fox jumps over the lazy dog dog .";
private static readonly char[] SingleSpace = new char[] { ' ' };
[Benchmark]
public int StringSegmentTest()
{
[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net60)]
public class EnumToString
{
public enum SomeValue
{
Value1,
Value2,
Value3
}
@vbondaryuk
vbondaryuk / PropertyGetterBenchmark.cs
Last active April 30, 2023 21:18
Property Getter
public class EventData
{
public string Message { get; set; }
}
[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net472, baseline: true)]
[SimpleJob(RuntimeMoniker.Net60)]
public class GetPropertyBench
{
[MemoryDiagnoser]
public class DictionaryAddOrUpdate
{
ConcurrentDictionary<int, int> cd = new ConcurrentDictionary<int, int>();
ConcurrentDictionary<int, int> cd1 = new ConcurrentDictionary<int, int>();
[Benchmark]
public void WithoutAllocation()
{
var value = 5;
[TestMethod]
[DataRow(new[] { 1, 2, 3 })]
[DataRow(new[] { 1, 3, 2 })]
public void Test1(int[] inputOrder)
{
var foo = new Foo();
var fooWrapper = new FooWrapper();
var threads = new[]
{
null,
using System.Threading;
public class Foo {
private int _currentStep;
public void First(Action printFirst)
{
// printFirst() outputs "first". Do not change or remove this line.
printFirst();
Interlocked.Increment(ref _currentStep);
import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {AppRoutingModule} from './app-routing.module';
import {AppComponent} from './app.component';
import {FormsModule} from '@angular/forms';
import {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http';
import {JwtInterceptor} from './interceptors/jwt.interceptor';
import {HttpErrorInterceptor} from './interceptors/http-error.interceptor';
import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
import {AuthenticationService} from '../shared/services/authentication.service';
@Injectable({providedIn: 'root'})
export class AuthGuard implements CanActivate {
constructor(
private router: Router,
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {AuthGuard} from './guards/app.guard';
const routes: Routes = [
{path: '', redirectTo: 'dashboard', pathMatch: 'full'},
{path: 'dashboard', loadChildren: './modules/dashboard/dashboard.module#DashboardModule', canActivate: [AuthGuard]},
{path: 'auth', loadChildren: './modules/login/login.module#LoginModule'},
{path: '**', redirectTo: 'dashboard', pathMatch: 'full'}
];