forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
45 lines (37 loc) · 1.14 KB
/
Program.cs
File metadata and controls
45 lines (37 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ServiceStack.Redis;
namespace RedisPerfTest
{
class Program
{
const string KeyMaster = "key:";
const string ValueMaster = "value:";
private const int Iterations = 1000;
private const int LogEveryTimes = 100;
static void Main(string[] args)
{
var host = args.Length > 0 ? args[0] : "localhost";
var port = args.Length > 1 ? int.Parse(args[1]) : 6379;
var redisClient = new RedisClient(host, port);
var before = DateTime.Now;
for (var i = 0; i < Iterations; i++)
{
var key = KeyMaster + i;
redisClient.Set(key, ValueMaster);
//if (i % LogEveryTimes == 0)
// Console.WriteLine("Time taken at {0}: {1}ms", i, (DateTime.Now - before).TotalMilliseconds);
}
for (int i = 0; i < Iterations; i++)
{
var key = KeyMaster + i;
redisClient.Get<string>(key);
//if (i % LogEveryTimes == 0)
// Console.WriteLine("Time taken at {0}: {1}ms", i, (DateTime.Now - before).TotalMilliseconds);
}
Console.WriteLine("Total Time Taken: {0}ms", (DateTime.Now - before).TotalMilliseconds);
}
}
}