Windows
- Grpc.Core や Grpc.Core.Api のみならこれだけでok
- .NET Core SDK のインストール
- VSビルドする場合、VS2019、.NET Framework 4.6.2 targeting pack をインストール
- csharp_ext だと、cmake か ninja あるいは bazel ビルドが必要。
void Main() | |
{ | |
var p1 = new Position { X = 2, Y = 0, }; | |
var p2 = new Position { X = 1, Y = 2, }; | |
var p3 = new Position(); | |
var p4 = new Position { X = 5, Y = 10, }; | |
var p5 = new Position { X = 50, }; | |
var p6 = new Position { Y = -10, }; | |
G(p1).Dump(); // 2 | |
G(p2).Dump(); // 0 |
void Main() | |
{ | |
var hoge = GetHoge(); | |
} | |
public IEnumerable<IHoge> GetHoge() | |
{ | |
var hoge = Enumerable.Range(0, 1).Select(x => new Hoge()); | |
return hoge; | |
} |
public static class Easing | |
{ | |
public static double Linear(double currentTime, double startValue, double changeValue, double duration) => changeValue * currentTime / duration + startValue; | |
// Quadratic (x2) | |
public static double InQuadratic(double currentTime, double startValue, double changeValue, double duration) | |
{ | |
currentTime /= duration; | |
return changeValue * Math.Pow(currentTime, 2) + startValue; | |
} |
void Main() | |
{ | |
var random = new Random(); | |
var data = Enumerable.Range(0, 10000) | |
.Select(x => TimeSpan.FromMilliseconds(random.Next(1, 500))) | |
.OrderBy(x => x) | |
.ToArray(); | |
var fastest = data[0]; | |
var slowest = data[^1]; |
void Main() | |
{ | |
var random = new Random(); | |
var data = Enumerable.Range(0, 10000) | |
.Select(x => TimeSpan.FromMilliseconds(random.Next(1, 500))) | |
.OrderBy(x => x) | |
.ToArray(); | |
Latencies(data).Dump(); | |
} |
async Task Main() | |
{ | |
var sw = Stopwatch.StartNew(); | |
// pool size = 50, runnning for 20sec | |
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(20)); | |
using var pool = new TaskPool<int>(50, cts.Token); | |
while (!cts.Token.IsCancellationRequested) | |
{ | |
pool.RegisterAsync(() => SendAsync(1)).FireAndForget(); | |
} |
void Main() | |
{ | |
Durations.FromString("10d").Dump(); | |
Durations.FromString("10h").Dump(); | |
Durations.FromString("10m").Dump(); | |
Durations.FromString("10s").Dump(); | |
Durations.FromString("100d10h10m10s").Dump(); | |
Durations.FromString("100d10h10s").Dump(); | |
Durations.FromString("0").Dump(); |
version: "3" | |
services: | |
mysql: | |
image: mysql:5.7.12 | |
ports: | |
- 3506:3306 | |
environment: | |
MYSQL_ROOT_PASSWORD: root |
void Main() | |
{ | |
var summary = BenchmarkRunner.Run<StringOutput>(); | |
} | |
[SimpleJob(RuntimeMoniker.NetCoreApp30, baseline: true)] | |
[SimpleJob(RuntimeMoniker.NetCoreApp31)] | |
[SimpleJob(RuntimeMoniker.NetCoreApp50)] | |
[RPlotExporter] | |
[MemoryDiagnoser] | |
public class StringOutput |