-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProgram.cs
80 lines (61 loc) · 2.34 KB
/
Program.cs
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace DbConnectorTestCases
{
public static partial class Program
{
private const string ConString = @"Data Source=SFK-A90\SQLEXPRESS;Initial Catalog=OrmLite;Persist Security Info=True;User ID=sa;Password=sfka90";
static void Main()
{
ExecuteFirstSet();
Console.ReadLine();
}
/// <summary>
/// Executes the set of methods (methods which does not do any mapping) for testing
/// </summary>
static void ExecuteFirstSet()
{
var executionTime = new List<string>();
for (var i = 0; i < 5; i++)
{
var stopwatch = Stopwatch.StartNew();
Console.WriteLine("======= TEST CASES STARTED =======");
SetDefaults();
ParametrizedQueries();
QueryResultsetTest();
TableValuedParms();
DataTableTest();
DataSetTest();
Console.WriteLine("\n======= TEST CASES ENDS =======");
stopwatch.Stop();
executionTime.Add(stopwatch.GetTimeString());
}
foreach (var item in executionTime)
{
Console.WriteLine("\nTime took to complete tests - {0}", item);
}
}
/// Reference :- http://stackoverflow.com/questions/16130232/find-execution-time-of-a-method
/// <summary>
/// Gets the time elapsed to know the execution time
/// </summary>
/// <param name="stopwatch"></param>
/// <param name="numberofDigits">Precision</param>
/// <returns></returns>
public static string GetTimeString(this Stopwatch stopwatch, int numberofDigits = 1)
{
var time = stopwatch.ElapsedTicks / (double)Stopwatch.Frequency;
if (time > 1)
return Math.Round(time, numberofDigits) + " s";
if (time > 1e-3)
return Math.Round(1e3 * time, numberofDigits) + " ms";
if (time > 1e-6)
return Math.Round(1e6 * time, numberofDigits) + " µs";
if (time > 1e-9)
return Math.Round(1e9 * time, numberofDigits) + " ns";
return stopwatch.ElapsedTicks + " ticks";
}
}
}