-
Notifications
You must be signed in to change notification settings - Fork 89
/
Program.cs
52 lines (43 loc) · 1.8 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
using BenchmarkDotNet.Running;
using Microsoft.Data.SqlClient;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;
using System;
using System.IO;
namespace OptimizeMePlease
{
/// <summary>
/// Steps:
///
/// 1. Create a database with name "OptimizeMePlease"
/// 2. Run application Debug/Release mode for the first time. IWillPopulateData method will get the script and populate
/// created db.
/// 3. Comment or delete IWillPopulateData() call from Main method.
/// 4. Go to BenchmarkService.cs class
/// 5. Start coding within GetAuthors_Optimized method
/// GOOD LUCK! :D
/// </summary>
public class Program
{
static void Main(string[] args)
{
//Debugging
//BenchmarkService benchmarkService = new BenchmarkService();
//var p = benchmarkService.GetAuthors_Optimized_Struct();
//var d = benchmarkService.GetAuthors_Optimized_Struct1();
//Comment me after first execution, please.
//IWillPopulateData();
BenchmarkRunner.Run<BenchmarkService>();
}
public static void IWillPopulateData()
{
string sqlConnectionString = @"Server=localhost;Database=OptimizeMePlease;Trusted_Connection=True;Integrated Security=true;MultipleActiveResultSets=true";
string workingDirectory = Environment.CurrentDirectory;
string path = Path.Combine(Directory.GetParent(workingDirectory).Parent.Parent.FullName, @"script.sql");
string script = File.ReadAllText(path);
SqlConnection conn = new SqlConnection(sqlConnectionString);
Server server = new Server(new ServerConnection(conn));
server.ConnectionContext.ExecuteNonQuery(script);
}
}
}