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
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
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();
File.Delete(@"tests\report.txt");
for (int g = 0; g < 30; g++)
{
pathin = @"tests\in" + g + ".txt";
pathresult = @"tests\out" + g + ".txt";
File.Copy(pathin, @"tests\in.txt", true);
File.Copy(pathresult, @"tests\result.txt", true);
sw.Restart();
//Запуск программы
System.Diagnostics.Process MyProc = new System.Diagnostics.Process();
MyProc.StartInfo.FileName = @"testing";
MyProc.Start();
double usingMemory = (double)MyProc.WorkingSet64 / (1024f * 1024f);
Console.WriteLine("Use :" + usingMemory);
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("tests/out.txt ");
StreamReader sr2 = new StreamReader("tests/result.txt");
StreamWriter report = new StreamWriter("tests/report.txt", true);
report.WriteLine("Test number {0}", g + 1);
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");
}
else
{
report.WriteLine("good test");
}
if (time <= 2000)
{
report.WriteLine("good time");
}
else
{
report.WriteLine("bad time");
}
if (usingMemory <= 512)
{
report.WriteLine("good memory");
report.WriteLine();
}
else
{
report.WriteLine("bad memory");
report.WriteLine();
}
sr1.Close();
sr2.Close();
report.Close();
}
Console.ReadLine();
}
}
}