using System using System Collections Generic using System Linq using

 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
81
82
83
84
85
86
87
88
89
90
91
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.IO;
using System.Threading;
namespace testLab4
{
class Program
{
[STAThread]
private static void Main(string[] args)
{
string pathin, pathresult;
int time;
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
for (int g = 0; g < 2; g++)
{
pathin = @"D:\tests\in" + g + ".txt";
pathresult = @"D:\tests\result" + g + ".txt";
File.Copy(pathin, @"D:\recin.txt", true);
File.Copy(pathresult, @"D:\\result.txt", true);
sw.Restart();
//Запуск программы
System.Diagnostics.Process MyProc = new System.Diagnostics.Process();
// MyProc.StartInfo.FileName = @"C:\hello.exe";
MyProc.StartInfo.FileName = @"C:\Windows\System32\notepad.exe";
MyProc.Start();
MyProc.WaitForExit();
Console.WriteLine(sw.ElapsedMilliseconds.ToString());
time = Convert.ToInt32(sw.ElapsedMilliseconds.ToString());
//сравнение 2 файлов
bool isNotEqual = false;
int lineNumber = 0;
int k = 0;
StreamReader sr1 = new StreamReader("D:\\recout.txt ");
StreamReader sr2 = new StreamReader("D:\\result.txt");
StreamWriter report = new StreamWriter("D:\\report.txt", true);
report.WriteLine("Test number {0}", g);
while (!sr1.EndOfStream && !sr2.EndOfStream)
{
k++;
string line1 = sr1.ReadLine();
string line2 = sr2.ReadLine();
if (line1 != line2)
{
isNotEqual = true;
lineNumber = k;
}
}
if (isNotEqual)
{
report.WriteLine("bad test");
// report.WriteLine();
}
else
{
report.WriteLine("good test");
// report.WriteLine();
}
if (time<=2000)
{
report.WriteLine("good time");
report.WriteLine();
}
else
{
report.WriteLine("bad time");
report.WriteLine();
}
sr1.Close();
sr2.Close();
report.Close();
}
Console.ReadLine();
}
}
}