-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStopWatch
60 lines (43 loc) · 1.18 KB
/
StopWatch
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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace GB
{
class Book
{
public string Title { get; set; }
public string Author { get; set; }
public string Genre { get; set; }
public bool IsFiction { get; set; }
}
class Program
{
static void Main(string[] args)
{
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
string numbers = "";
for (int i = 0; i < 1000; i++)
{
numbers += i;
}
stopwatch.Stop();
Console.WriteLine("Time Elapsed: {0}", stopwatch.Elapsed);
stopwatch.Reset();
stopwatch.Start();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 1000; i++)
{
sb.Append(i);
}
//Console.WriteLine(sb.ToString());
stopwatch.Stop();
Console.WriteLine("Time Elapsed: {0}", stopwatch.Elapsed);
Console.ReadLine();
}
}
}