Skip to content

Commit

Permalink
More perf tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Dec 20, 2017
1 parent 00da36b commit ab93e49
Showing 1 changed file with 44 additions and 3 deletions.
47 changes: 44 additions & 3 deletions src/MonkeyCache.TestsShared/BarrelTests.cs
Expand Up @@ -295,6 +295,43 @@ public void DoesNotExistsTest()
#endregion

#region Performance Tests

[TestMethod]
public void PerformanceTestsJson1()
{
PerformanceTestRunner(1, true, 1, true);
}

[TestMethod]
public void PerformanceTestsJson10()
{
PerformanceTestRunner(1, true, 1000, true);
}

[TestMethod]
public void PerformanceTestsJson100()
{
PerformanceTestRunner(1, true, 100, true);
}

[TestMethod]
public void PerformanceTestsJson1000()
{
PerformanceTestRunner(1, true, 1000, true);
}

[TestMethod]
public void PerformanceTestsMultiThreadedJson()
{
PerformanceTestRunner(4, false, 1000, true);
}

[TestMethod]
public void PerformanceTestsMultiThreadedWithDuplicatesJson()
{
PerformanceTestRunner(4, true, 1000, true);
}

[TestMethod]
public void PerformanceTests()
{
Expand All @@ -313,7 +350,7 @@ public void PerformanceTestsMultiThreadedWithDuplicates()
PerformanceTestRunner(4, true, 1000);
}

void PerformanceTestRunner (int threads, bool allowDuplicateKeys, int keysPerThread)
void PerformanceTestRunner (int threads, bool allowDuplicateKeys, int keysPerThread, bool useJson = false)
{
var tasks = new List<Task>();

Expand All @@ -335,8 +372,12 @@ void PerformanceTestRunner (int threads, bool allowDuplicateKeys, int keysPerThr
// Add a lot of items
foreach (var key in keys)
barrel.Add(key: key, data: monkeys, expireIn: TimeSpan.FromDays(1));
{
if(useJson)
barrel.Add(key: key, data: json, expireIn: TimeSpan.FromDays(1));
else
barrel.Add(key: key, data: monkeys, expireIn: TimeSpan.FromDays(1));
}
stopwatch.Stop();
Debug.WriteLine($"Add ({tId}) took {stopwatch.ElapsedMilliseconds} ms");
stopwatch.Restart();
Expand Down

0 comments on commit ab93e49

Please sign in to comment.