Commit 86039446 authored by Nick Craver's avatar Nick Craver

Cleanup: test programs

parent b0e6ac2e
...@@ -11,11 +11,9 @@ ...@@ -11,11 +11,9 @@
namespace BasicTest namespace BasicTest
{ {
internal static class Program
static class Program
{ {
static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly).Run(args); private static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).GetTypeInfo().Assembly).Run(args);
} }
internal class CustomConfig : ManualConfig internal class CustomConfig : ManualConfig
{ {
...@@ -37,8 +35,8 @@ public CustomConfig() ...@@ -37,8 +35,8 @@ public CustomConfig()
[Config(typeof(CustomConfig))] [Config(typeof(CustomConfig))]
public class RedisBenchmarks : IDisposable public class RedisBenchmarks : IDisposable
{ {
ConnectionMultiplexer connection; private ConnectionMultiplexer connection;
IDatabase db; private IDatabase db;
/// <summary> /// <summary>
/// Create /// Create
/// </summary> /// </summary>
...@@ -54,8 +52,7 @@ void IDisposable.Dispose() ...@@ -54,8 +52,7 @@ void IDisposable.Dispose()
connection = null; connection = null;
} }
private const int COUNT = 10000;
const int COUNT = 10000;
/// <summary> /// <summary>
/// Run INCRBY lots of times /// Run INCRBY lots of times
...@@ -78,8 +75,7 @@ public int Execute() ...@@ -78,8 +75,7 @@ public int Execute()
db.StringIncrement(counter, x, CommandFlags.FireAndForget); db.StringIncrement(counter, x, CommandFlags.FireAndForget);
} }
int actual = (int)db.StringGet(counter); int actual = (int)db.StringGet(counter);
if (actual != expected) throw new InvalidOperationException( if (actual != expected) throw new InvalidOperationException($"expected: {expected}, actual: {actual}");
$"expected: {expected}, actual: {actual}");
return actual; return actual;
} }
} }
......
...@@ -12,14 +12,14 @@ namespace BasicTest ...@@ -12,14 +12,14 @@ namespace BasicTest
[Config(typeof(CustomConfig))] [Config(typeof(CustomConfig))]
public class TextBenchmarks public class TextBenchmarks
{ {
readonly string[] corpus; private readonly string[] corpus;
readonly byte[] buffer; private readonly byte[] buffer;
public TextBenchmarks() public TextBenchmarks()
{ {
corpus = File.ReadAllLines("t8.shakespeare.txt"); corpus = File.ReadAllLines("t8.shakespeare.txt");
buffer = new byte[enc.GetMaxByteCount(corpus.Max(x => x.Length))]; buffer = new byte[enc.GetMaxByteCount(corpus.Max(x => x.Length))];
} }
static readonly Encoding enc = Encoding.UTF8; private static readonly Encoding enc = Encoding.UTF8;
[Benchmark] [Benchmark]
public long Measure() public long Measure()
...@@ -51,7 +51,6 @@ public long MeasureVectorized() ...@@ -51,7 +51,6 @@ public long MeasureVectorized()
return total; return total;
} }
[Benchmark] [Benchmark]
public long MeasureAndEncodeVectorized() public long MeasureAndEncodeVectorized()
{ {
...@@ -66,9 +65,7 @@ public long MeasureAndEncodeVectorized() ...@@ -66,9 +65,7 @@ public long MeasureAndEncodeVectorized()
return total; return total;
} }
private static readonly Vector<ushort> NonAsciiMask = new Vector<ushort>(0xFF80);
static readonly Vector<ushort> NonAsciiMask = new Vector<ushort>(0xFF80);
internal static internal static
#if NET47 #if NET47
unsafe unsafe
......
using System; using System;
using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.IO.Pipelines;
using System.Linq; using System.Linq;
using StackExchange.Redis; using StackExchange.Redis;
class Program namespace TestConsole
{ {
static int Main() internal static class Program
{
private static int Main()
{ {
var s = new StringWriter(); var s = new StringWriter();
var watch = Stopwatch.StartNew(); var watch = Stopwatch.StartNew();
...@@ -45,13 +45,12 @@ static int Main() ...@@ -45,13 +45,12 @@ static int Main()
//Console.WriteLine(s); //Console.WriteLine(s);
Console.ReadKey(); Console.ReadKey();
} }
} }
private static void Execute(ConnectionMultiplexer conn) private static void Execute(ConnectionMultiplexer conn)
{ {
int pageSize = 100; const int pageSize = 100;
RedisKey key = nameof(Execute); RedisKey key = nameof(Execute);
var db = conn.GetDatabase(); var db = conn.GetDatabase();
db.KeyDelete(key); db.KeyDelete(key);
...@@ -63,4 +62,5 @@ private static void Execute(ConnectionMultiplexer conn) ...@@ -63,4 +62,5 @@ private static void Execute(ConnectionMultiplexer conn)
Console.WriteLine(count == 2000 ? "Pass" : "Fail"); Console.WriteLine(count == 2000 ? "Pass" : "Fail");
} }
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment