-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathmyStringConcat.cs
More file actions
46 lines (44 loc) · 1.31 KB
/
myStringConcat.cs
File metadata and controls
46 lines (44 loc) · 1.31 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
46
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
using System;
using System.Diagnostics;
namespace SQLBench
{
class myStringConcat
{
//
// Written by the Microsoft CSS SQL Networking Team
//
// Performs a string concatenation benchmark - tests CPU and Memory performance
//
string mystring;
public myStringConcat()
{
mystring = "";
}
public String MyConcatination()
{
Stopwatch mytimer = new Stopwatch();
try
{
mytimer.Start();
for (int a = 0; a < 20000; a++)
{
if (mystring.Length <= 2000)
{
if (((uint)a & 1) <= 0U)
mystring += "CCCCCCCCCCCCCCCCCCCCCC";
else
mystring += "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
}
else
mystring = "";
}
mytimer.Stop();
}
catch (Exception message) { return message.Message; }
TimeSpan Totaltime = mytimer.Elapsed;
return Convert.ToString(20000/ Totaltime.TotalMilliseconds);
}
}
}