CKTIS / C#
performance and complexity: praktická reference
performance and complexity: praktická reference: Výkon zahrnuje čas, alokace, I/O, souběžnost a charakteristiky dat.
Verze: C# language and .NET 10 reference runtime
Syntaxe
// performanceVýkon zahrnuje čas, alokace, I/O, souběžnost a charakteristiky dat.
Před optimalizací měřte realistickým benchmarkem a profilujte dominantní náklad.
Mikrooptimalizace může zhoršit čitelnost bez vlivu na celkový výsledek.
Warm-up JIT, GC, cache a variabilita prostředí zkreslují jednotlivé měření.
Úplný program skutečně používá performance and complexity; přesně očekávaný stdout je 5050.
Příklady
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
var values = Enumerable.Range(1, 100).ToArray(); var sum = 0; foreach (var value in values) sum += value; Console.WriteLine(sum);
Výsledek
5050
Úplný program skutečně používá `performance and complexity`; přesně očekávaný stdout je `5050`.